Skip to content

Support webcrypto hash algorithm arguments in node.js crypto hash apis #56464

Open
@jasnell

Description

What is the problem this feature will solve?

In Node.js, we would do crypto.createHash('sha256') ... in web crypto we can do either crypto.subtle.digest('sha256', ...) or crypto.subtle.digest({ name: 'sha256' }, ...) (string or object). For consistency, it would be helpful to be able to support the webcrypto style arguments in the Node.js APIs also..

What is the feature you are proposing to solve the problem?

const { createHash } = require('node:crypto');

const algorithm = { name: 'sha256' };

// Support the same argument types in createHash/createHmac that are supported in web crypto..

const hash = createHash(algorithm);
// ...

What alternatives have you considered?

No response

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.webcrypto

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions