![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a problem with HMACSHA512 ComputeHash fnction. I need to get same result on every computer that runs my software. But I have got different result on two computers (on other 20 results are correct). They are using same version, same function with same parameters and this begin to happen this week. Is this a bug? What hash function will produce same result on different computers with different OSs? My code: public static string HashIt(byte[] hashKey, byte[] myKey, HashEncryptionType hashType) { System.Security.Cryptography.HMAC hash; switch (hashType) { case HashEncryptionType.SHA1: hash = new HMACSHA1(hashKey); break; case HashEncryptionType.SHA256: hash = new HMACSHA256(hashKey); break; case HashEncryptionType.SHA384: hash = new HMACSHA384(hashKey); break; case HashEncryptionType.SHA512: hash = new HMACSHA512(hashKey); break; default: hash = new HMACSHA512(hashKey); break; } hash.ComputeHash(myKey); string hashedBytes = Convert.ToBase64String(hash.Hash); hash.Clear(); return hashedBytes; } Nikolay Unguzov |
#3
| |||
| |||
|
|
The problem is caused by microsoft update: .NET 2.0 SP1 In .NET 2.0 SP1 HMAC SHA1 and SHA256 returns same values as in .NET 2.0, but SHA384 and SHA512 returns different values... I'm not sure if this is new bug, or fix of old bug, but I'm sure that this is nod a good policy. Nikolay Unguzov "news.microsoft.com" <unguzov (AT) abv (DOT) bg> wrote in message news:eJbhBpNPIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl... Hi, I have a problem with HMACSHA512 ComputeHash fnction. I need to get same result on every computer that runs my software. But I have got different result on two computers (on other 20 results are correct). They are using same version, same function with same parameters and this begin to happen this week. Is this a bug? What hash function will produce same result on different computers with different OSs? My code: public static string HashIt(byte[] hashKey, byte[] myKey, HashEncryptionType hashType) { System.Security.Cryptography.HMAC hash; switch (hashType) { case HashEncryptionType.SHA1: hash = new HMACSHA1(hashKey); break; case HashEncryptionType.SHA256: hash = new HMACSHA256(hashKey); break; case HashEncryptionType.SHA384: hash = new HMACSHA384(hashKey); break; case HashEncryptionType.SHA512: hash = new HMACSHA512(hashKey); break; default: hash = new HMACSHA512(hashKey); break; } hash.ComputeHash(myKey); string hashedBytes = Convert.ToBase64String(hash.Hash); hash.Clear(); return hashedBytes; } Nikolay Unguzov |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |