oven-sh/bun
View on GitHubHashing functions from `node:crypto` don't support the same inputs as Node.js
Open
#18,019 opened on Mar 9, 2025
buggood first issuenode:crypto
Description
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