Python hmac и C# hmacC#

Место общения программистов C#
Anonymous
Python hmac и C# hmac

Сообщение Anonymous »

У нас есть веб-сервис Python. В качестве параметра ему нужен хеш.
Хеш в Python генерируется таким образом.

Код: Выделить всё

    hashed_data = hmac.new("ant", "bat", hashlib.sha1)
print hashed_data.hexdigest()
Теперь я генерирую хэш из C#.

Код: Выделить всё

    ASCIIEncoding encoder = new ASCIIEncoding();
Byte[] code = encoder.GetBytes("ant");
HMACSHA1 hmSha1 = new HMACSHA1(code);
Byte[] hashMe = encoder.GetBytes("bat");
Byte[] hmBytes = hmSha1.ComputeHash(hashMe);
Console.WriteLine(Convert.ToBase64String(hmBytes));
Однако у меня другой результат.

Должен ли я изменить порядок хеширования?

Спасибо,

Джон

Подробнее здесь: https://stackoverflow.com/questions/117 ... sharp-hmac

Вернуться в «C#»