crypto.getCipherInfo(nameOrNid[, options])


  • nameOrNid <string> | <number> 要查询的密码的名称或 nid。
  • options <Object>
    • keyLength <number> 一个测试密钥长度。
    • ivLength <number> 一个测试 IV 长度。
  • 返回:<Object>
    • name <string> 密码名称
    • nid <number> 密文的 nid
    • blockSize <number> 密码的块大小(以字节为单位)。当 mode'stream' 时,此属性将被省略。
    • ivLength <number> 以字节为单位的预期或默认初始化向量长度。如果加密算法不使用初始化向量,则省略此属性。
    • keyLength <number> 期望的或默认的密钥长度(以字节为单位)。
    • mode <string> 加密模式。可选值为 'cbc''ccm''cfb''ctr''ecb''gcm''ocb''ofb''stream''wrap''xts'

返回有关给定密码的信息。

【Returns information about a given cipher.】

某些加密算法接受可变长度的密钥和初始化向量。默认情况下,crypto.getCipherInfo() 方法将返回这些加密算法的默认值。要测试给定的密钥长度或初始化向量长度是否适用于指定的加密算法,请使用 keyLengthivLength 选项。如果给定的值不可接受,将返回 undefined

【Some ciphers accept variable length keys and initialization vectors. By default, the crypto.getCipherInfo() method will return the default values for these ciphers. To test if a given key length or iv length is acceptable for given cipher, use the keyLength and ivLength options. If the given values are unacceptable, undefined will be returned.】