HMAC String return incorrect hash

Dec 18, 2012 at 6:40 AM


First, i want to thanks you for this great hash lib. It contain almost all hash function i can think of.

It's seems that there is defect when calculating string with HMAC, the return value is incorrect.

for example i used this code to get hash from string with HMAC:

IHMAC hmac = HashFactory.HMAC.CreateHMAC(HashFunction);           

hmac.Key = Converters.ConvertStringToBytes(a_key,Encoding.ASCII);           

Hash = hmac.ComputeBytes(Converters.ConvertStringToBytes(a_text)).ToString(); 

also i tried hmac.computeString(...)

Than the return result is:

File with HMAC: 

MD5: 60B7EC6F-573C90A9-D0AE21D2-24C9891E

SHA1: 8EB34B4F-6AAE2A3F-007B6ADC-65273116-DF2BEFA1

Text with HMAC

MD5: C1D742AB-959C2C71-4AD747A2-F4C2C5FD

SHA1: 366A5F52-57219F71-4A5E88CD-8F901438-2328C174

The result of both text and file should be the same (text = file content).

The workaround is to create file that contain the string and then compute the hash but....


Thanks for any help.