Skip to content

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

@lilnasy

Description

@lilnasy

Version: Deno 2.2.3

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, Deno throws an error.

> deno x.js 
error: Uncaught (in promise) Error: Digest method not supported: shake-128
    at new Hash (ext:deno_node/internal/crypto/hash.ts:33:93)
    at createHash (ext:deno_node/internal/crypto/hash.ts:174:10)
    at Object.hash (node:crypto:29:17)
    at file:///home/x.js:3:20

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoRelated to node:crypto or WebCrypto

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions