I have a nodejs code which generate signature based on current time stamp:
var crypto = require('crypto');
var nonce = new Date().getTime();
var signature = function(nonce, secretKey) {
var signature = crypto.createHmac('sha256', Buffer.from(secretKey, 'utf8')).update(Buffer.from(nonce, 'utf8')).digest('base64');
return signature;
}
I am converting this code into browser js but i did not succeed in my task. I took reference from this link: nodejs crypto module vs crypto-js but did not work.
if nonce=1518440585425
and secret=9IeVABv94EQBnT6Mn73742kBZOmzFpsM+c62LU9b/h4=
it should give this signature=blI2ILR8MW4ParkT4R1vvVOXF42gJOAVPgEJtZT7Ivo=
Your
nodejs
signature generation code will be equivalent to thiscrypto js
code:You will need to include these js in your HTML file: