oven-sh/bun

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

Open

#18,019 创建于 2025年3月9日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (90,348 star) (4,486 fork)batch import
buggood first issuenode:crypto

描述

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

贡献者指南

Hashing functions from `node:crypto` don't support the same inputs as Node.js · oven-sh/bun#18019 | Good First Issue