0

for the node.js crypto command:

crypto.createHmac('this is a test', key);

What is node expecting for key's encoding?

utf8? a binary buffer?

1

Since javascript uses UTF-16 strings, I suspect it is expecting a UTF-16 encoded string. Just to clarify, your first parameter should be a hash algorithm ('sha1', 'md5', etc.) not the data to be encrypted.

0

First parameter should be the algorythm, not the input to be HMACed, should be one of the following -

MD5
SHA
SHA1
SHA256
SHA384

The key is a secret / salt string.

crypto.createHmac returns a stream, you write your input into it and once you start reading, it returns the computed digests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.