Guest User

Untitled

a guest
Nov 23rd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Generic hmac digest creation to prove authenticity
  2. var crypto = require('crypto');
  3. function createSignature(timestamp, apiKey, apiSecret){
  4. var hmac = crypto.createHmac('sha256', apiSecret );
  5. hmac.update( timestamp + apiKey );
  6. return hmac.digest('hex');
  7. }
  8.  
  9. function createAuthRequest(apiKey, apiSecret ){
  10. var timestamp = Math.floor(Date.now() / 1000); // Note: java and javascript timestamp presented in miliseconds
  11. var args = { e: 'auth', auth: { key: apiKey,
  12. signature: createSignature(timestamp, apiKey, apiSecret), timestamp: timestamp } };
  13. var authMessage = JSON.stringify( args );
  14. return authMessage;
  15. }
Add Comment
Please, Sign In to add comment