oven-sh/bun
Hashing functions from `node:crypto` don't support the same inputs as Node.js
クローズ
#18,019 opened on 2025/03/09
buggood first issuenode:crypto
Repository metrics
- Stars
- (90,348 個のスター)
- PR merge metrics
- (平均マージ 1d 17h) (30d で 357 merged PRs)
説明
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