Thursday, 27 April 2017

Issue while base64_encode hash_hmac in php and crypto in nodejs

In php I have

base64_encode(hash_hmac('sha512', "GET\n{$uri}", $privateKey));

and to do the same operation in nodejs i have

crypto.createHmac('sha512', privateKey).update('GET' + '\n' + uri).digest('base64');

But the value in both cases doesn't comes out to be same. The length of encoded string in php is much greater than encode string in nodejs. Is there anything implemented wrong in nodejs?



via Rajat Nigam

No comments:

Post a Comment