I have C# function below;
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 trying to convert this code in Javascript. I found this library as helper.
Here is code I am using;
<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> but code above is not generating same output from C# code. How can I achieve it in Javascript?