crypto.getMacs()


稳定性: 1.2 - 发布候选版

  • 返回:<string[]> 一个包含可获取 MAC 实现的已排序、全小写名称和别名的新数组。

返回由已加载的 OpenSSL 提供程序暴露的、与活动默认属性查询匹配的 MAC 名称。重复的名称和数字 OID 别名会被忽略。在没有 OpenSSL EVP_MAC 支持的构建中,此函数会返回一个空数组。

🌐 Returns MAC names exposed by loaded OpenSSL providers that match the active default property query. Duplicate names and numeric OID aliases are omitted. On builds without OpenSSL EVP_MAC support, this function returns an empty array.

返回的名称描述了 OpenSSL 可以获取的实现。它们并不保证 crypto.createMac() 可以在没有额外选项的情况下初始化 MAC。提供者可能需要额外的参数或具有特定算法属性的密钥,而且它可能会暴露这个 API 不支持的参数。

🌐 The returned names describe implementations that OpenSSL can fetch. They do not guarantee that crypto.createMac() can initialize the MAC without additional options. A provider can require additional parameters or a key with algorithm-specific properties, and it can expose parameters that this API does not support.

在使用 crypto.setFips() 成功更改 FIPS 模式后,后续调用会反映新的模式,并且新创建的 Mac 对象会使用它。现有的 Mac 对象仍然使用它们创建时选择的提供程序实现。

🌐 After a successful FIPS mode change made with crypto.setFips(), subsequent calls reflect the new mode, and newly created Mac objects use it. Existing Mac objects continue using the provider implementation selected when they were created.

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

console.log(getMacs());
// ['blake2bmac', 'blake2smac', 'cmac', 'gmac', 'hmac', ...]