Python hmac and C# hmac

Viewed 4411

We have a python web service. It needs a hash as a parameter. The hash in python is generated this way.

    hashed_data = hmac.new("ant", "bat", hashlib.sha1)
    print hashed_data.hexdigest()

Now, this is how I generate the hash from 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));

However, I'm coming out with different result.

Should I change the order of the hashing?

Thank you,

Jon

1 Answers
Related