Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HackinwaleDev/616efdf8c84197970777bf8f460a3fc0 to your computer and use it in GitHub Desktop.
Save HackinwaleDev/616efdf8c84197970777bf8f460a3fc0 to your computer and use it in GitHub Desktop.
The implementation has been done to my best of knowledge and also research the web for standard pseudocode yet I keep getting error. Please take a look.
// import the useful packages
const crypto = require('crypto');
const sha256 = require('sha256');
// defining the variables
let nonce = crypto.randomBytes(16).toString('base64');
let key = sha256.x2(WALLET_ID + WALLET_PASSWORD); // to double hash
let msg = WALLET_ID + nonce;
let headers = { // will be properly defined soon
"Access-Nonce": nonce,
"Access-Signature": HMAC_signature
}
// create the hmac util here
function HMAC(key, msg) {
let hmac = crypto.createHmac('sha256', key);
hmac.update(msg, 'utf8');
return hmac.digest();
}
// Signing the get requesst with HMAC keys
let HMAC_signature = HMAC(key, msg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment