Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import hmac
- import base64
- request = "Hello World";
- secret = "MySecret"
- requestBytes = bytes(request.encode('utf-8'))
- secretBytes = bytes(secret.encode('utf-8'))
- hmacConversion = hmac.new(secretBytes, requestBytes, digestmod=hashlib.sha256).digest()
- signature = base64.b64encode(hmacConversion)
- print(signature)
- b'm4nZSWE3Y/tPXToy/0cJMGpR2qpsXgCnF3tsSiZtYt0='
- var secret = "Hello World";
- var body = "MySecret";
- var hmac = crypto.createHmac("sha256", secret)
- .update(Buffer.from(body, 'utf-8'))
- .digest('hex');
- console.log(hmac);
- var hmac2 = crypto.createHmac("sha256", secret)
- .update(body, 'utf-8')
- .digest('hex');
- console.log(hmac2);
- f1f157335b0982cbba94290163d61582a87352817788b793238817dd631c26d4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement