网络加密 API


\Web Crypto API

版本历史
版本变更
v16.17.0

删除了专有的 'node.keyObject' 导入/导出格式。

v16.17.0

删除了专有的 'NODE-DSA''NODE-DH''NODE-SCRYPT' 算法。

v16.17.0

添加了 'Ed25519''Ed448''X25519''X448' 算法。

v16.17.0

删除了专有的 'NODE-ED25519''NODE-ED448' 算法。

v16.17.0

'ECDH' 算法中删除了专有的 'NODE-X25519''NODE-X448' 命名曲线。

稳定性: 1 - 实验性的

\Stability: 1 - Experimental

Node.js 提供了标准 网络加密 API 的实现。

\Node.js provides an implementation of the standard Web Crypto API.

使用 require('node:crypto').webcrypto 访问此模块。

\Use require('node:crypto').webcrypto to access this module.

const { subtle } = require('node:crypto').webcrypto;
(async function() {
 const key = await subtle.generateKey({
 name: 'HMAC',
 hash: 'SHA-256',
 length: 256
 }, true, ['sign', 'verify']);
 const enc = new TextEncoder();
 const message = enc.encode('I love cupcakes');
 const digest = await subtle.sign({
 name: 'HMAC'
 }, key, message);
})(); 

AltStyle によって変換されたページ (->オリジナル) /