Hello,
In an app we are calculating a SHA1Hmac in java using the following:
SecretKey key = new SecretKeySpec(secret, "HmacSHA1");
Mac m = Mac.getInstance("HmacSHA1");
m.init(key);
byte[] hmac = m.doFinal(data);
And later, the hmac is verified in C# - on a SmartCard - using:
HMACSHA1 hmacSha = new HMACSHA1(secret);
hmacSha.Initialize();
byte[] hmac = hmacSha.ComputeHash(data);
However, the result is not the same. Did I overlook something important?
The inputs seem to be the same. Here some sample inputs:
Data: 546573746461746131323341fa3c35
Key: 6d795472616e73616374696f6e536563726574
Result Java: 37dbde318b5e88acbd846775e38b08fe4d15dac6
Result C#: dd626b0be6ae78b09352a0e39f4d0e30bb3f8eb9
I wouldn't mind to implement my own hmacsha1 on both platforms, but using what already exists....
Thanks!