I'm having trouble calculating the same hash in PHP since I'm in C # .NET.
In C #, I have the following:
HMAC hasher = new HMACSHA256(Encoding.UTF8.GetBytes("secret"));
byte[] data = hasher.ComputeHash(Encoding.UTF8.GetBytes("2012-10-01T17:48:56"));
Convert.ToBase64String(data);
Which produces something like:
yBV7ZfAyT1FwO5sGEVd3aPYUfBz9geN6ghK9RO68jwo =
In PHP, I thought this would calculate the hash in the same way:
$hmac = hash_hmac("sha256", "2012-10-01T17:48:56", "secret");
$hmac = base64_encode($hmac);
However, it produces a much larger hash:
YzgxNTdiNjVmMDMyNGY1MTcwM2I5YjA2MTE1Nzc3NjhmNjE0N2MxY2ZkODFlMzdhODIxMmJkNDRlZWJjOGYwYQ ==
source
share