crypto.getHashes()


  • 返回:<string[]> 支持的哈希算法名称的数组,例如 'RSA-SHA256'。哈希算法也称为“摘要”算法。

这是 Node.js 关于当前进程中 crypto.createHash() 和 crypto.hash() 可用哈希算法的权威列表。在 OpenSSL 3 或更高版本中,这个列表取决于已加载的提供程序以及首次生成列表时生效的默认属性查询。一些列出的算法可能需要特定 API 的选项,例如 XOF 哈希函数的 outputLength。

🌐 This is the authoritative Node.js list of hash algorithms available to crypto.createHash() and crypto.hash() in the current process. With OpenSSL 3 or later, the list depends on the loaded providers and the default property query in effect when the list is first generated. Some listed algorithms can require API-specific options, such as outputLength for XOF hash functions.

列出的哈希算法不一定被那些将摘要与其他加密操作(如 HMAC、密钥派生或签名)结合的 API 支持。这些操作可能会有额外的限制。

🌐 A listed hash algorithm is not necessarily supported by APIs that combine a digest with another cryptographic operation, such as HMAC, key derivation, or signing. Those operations can apply additional restrictions.

const {
  getHashes,
} = await import('node:crypto');

console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]const {
  getHashes,
} = require('node:crypto');

console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]