Below is a C# function that I have;
private string GetEncyptionData(string encryptionKey)
{
string hashString = string.Format("{{timestamp:{0},client_id:{1}}}", Timestamp, ClientId);
HMAC hmac = HMAC.Create();
hmac.Key = Guid.Parse(encryptionKey).ToByteArray();
byte[] hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(hashString));
string encData = Convert.ToBase64String(hash);
return encData;
}
I am attempting to convert this code into Javascript. In my search for solutions, I stumbled upon this library as a useful tool.
Here is the code I currently have in Javascript;
<script>
var timestamp = 1424890904;
var client_id = "496ADAA8-36D0-4B65-A9EF-EE4E3659910D";
var EncryptionKey = "E69B1B7D-8DFD-4DEA-824A-8D43B42BECC5";
var message = "{timestamp:{0},client_id:{1}}".replace("{0}", timestamp).replace("{1}", client_id);
var hash = CryptoJS.HmacSHA1(message, EncryptionKey);
var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
alert(hashInBase64);
</script>
However, the above code does not produce the same output as the C# code. How can I achieve parity between the two codes in Javascript?