Reputation: 12487
I have some code which works in nodejs:
// Store Credentials
var userName = "username";
var sharedSecret = "secret";
// Build Header
var date = new Date();
var nonce = md5(Math.random());
var nonce_ts = date.toISOString().replace(/(\.\d\d\dZ)/ ,'Z');
var digest = (new Buffer(sha1(nonce + nonce_ts + sharedSecret)).toString('base64'));
alert(digest);
I understand both md5 and buffer don't form part of JS and are nodeJS. There is a regular JS buffer implementation but it seems very complex.
Is there a simpler way to still get the digest var created without having to use the buffer, as it doesn't seem hugely complicated.
Upvotes: 0
Views: 91
Reputation: 290
You can use https://nodejs.org/api/crypto.html Specifically look at createHash and createHmac methods. After you created your hash you can use .digest('base64') to get the base64 formatted hash
Upvotes: 1