Skip to content

Hashing functions from node:crypto don't support the same inputs as Node.js #18019

@lilnasy

Description

@lilnasy

What version of Bun is running?

1.2.4+fd9a5ea66

What platform is your computer?

Linux 6.1.91-060191-generic x86_64 x86_64, the issues isn't platform specific

What steps can reproduce the bug?

The following code...

import crypto from "node:crypto"

console.log(crypto.hash("shake-128", "", "base64url"))

...runs successfully on node.js and logs...

> node x.js 
f5wrpOiPgn1hYEVQdgWFPg

However, Bun throws an error.

> bun x.js 
1 | import crypto from "node:crypto"
2 | 
3 | console.log(crypto.hash("shake-128", "", "base64url"))
                       ^
TypeError: Unsupported algorithm "shake-128"
 code: "ERR_INVALID_ARG_TYPE"

      at /workspace/x.js:3:20

Bun v1.2.4 (Linux x64)

Bun does support the actual algorithms. For example, using "shake128" (without the hyphen) does work. Bun does not support the same aliases as Node.js, creating interop issues.

What is the expected behavior?

Same as Node.js

What do you see instead?

ERR_INVALID_ARG_TYPE

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueSomething that would be good for new contributorsnode:crypto

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions