Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import hashlib
  2. import hmac
  3. import base64
  4.  
  5. request = "Hello World";
  6. secret = "MySecret"
  7.  
  8. requestBytes = bytes(request.encode('utf-8'))
  9. secretBytes = bytes(secret.encode('utf-8'))
  10. hmacConversion = hmac.new(secretBytes, requestBytes, digestmod=hashlib.sha256).digest()
  11. signature = base64.b64encode(hmacConversion)
  12. print(signature)
  13.  
  14. b'm4nZSWE3Y/tPXToy/0cJMGpR2qpsXgCnF3tsSiZtYt0='
  15.  
  16. var secret = "Hello World";
  17. var body = "MySecret";
  18.  
  19. var hmac = crypto.createHmac("sha256", secret)
  20. .update(Buffer.from(body, 'utf-8'))
  21. .digest('hex');
  22. console.log(hmac);
  23.  
  24.  
  25. var hmac2 = crypto.createHmac("sha256", secret)
  26. .update(body, 'utf-8')
  27. .digest('hex');
  28. console.log(hmac2);
  29.  
  30. f1f157335b0982cbba94290163d61582a87352817788b793238817dd631c26d4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement