Skip to content

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

Closed

Description

@yi-ge

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

Activity

  1. yi-ge commented on May 17, 2016

    @yi-ge
    Author

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

  2. jasnell commented on May 17, 2016

    @jasnell
    Member

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

  3. addaleax commented on May 17, 2016

    @addaleax
    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.

  4. added
    invalidIssues and PRs that are invalid.
    cryptoIssues and PRs related to the crypto subsystem.
    on Jun 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.invalidIssues and PRs that are invalid.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions