Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js 5/6 crypto.createHash BUG #6813

Closed
yi-ge opened this issue May 17, 2016 · 3 comments
Closed

Node.js 5/6 crypto.createHash BUG #6813

yi-ge opened this issue May 17, 2016 · 3 comments
Labels
crypto Issues and PRs related to the crypto subsystem. invalid Issues and PRs that are invalid.

Comments

@yi-ge
Copy link

yi-ge commented May 17, 2016

Windows and Mac,Node.js v5/v6:

var a = '010203334455667788AF02';

console.log(md5(Buffer(a,'hex').toString('binary'),'hex'));

echo : 9f4eeb2dc8cfc04768149dfb1036009c

Windows and Mac,Node.js v4/0.10.29:

var a = '010203334455667788AF02';

console.log(md5(Buffer(a,'hex').toString('binary'),'hex'));

echo : f4cb7e6847b063001b72646517a9f4c3

@yi-ge
Copy link
Author

yi-ge commented May 17, 2016

crypto.createHash('md5').update(str, 'binary').digest(type || 'binary'); sorry

@yi-ge yi-ge closed this as completed May 17, 2016
@jasnell
Copy link
Member

jasnell commented May 17, 2016

Yes, the default encoding for digests was changed to utf8 in v5/v6. In v4 and earlier it was binary.

@addaleax
Copy link
Member

@wy373226722 Why are you converting the input to a “binary” string anyway? MD5 and other hashes convert any input you pass to them to Buffers back anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. invalid Issues and PRs that are invalid.
Projects
None yet
Development

No branches or pull requests

4 participants