crypto.privateDecrypt(privateKey, buffer)

  • privateKey {Object | string | Buffer | KeyObject}
    • oaepHash {string} The hash function to use for OAEP padding and MGF1. Default: 'sha1'
    • oaepLabel {Buffer | TypedArray | DataView} The label to use for OAEP padding. If not specified, no label is used.
    • padding {crypto.constants} An optional padding value defined in crypto.constants, which may be: crypto.constants.RSA_NO_PADDING, crypto.constants.RSA_PKCS1_PADDING, or crypto.constants.RSA_PKCS1_OAEP_PADDING.
  • buffer {Buffer | TypedArray | DataView}
  • Returns: {Buffer} A new Buffer with the decrypted content.

Decrypts buffer with privateKey. buffer was previously encrypted using the corresponding public key, for example using [crypto.publicEncrypt()][].

If privateKey is not a [KeyObject][], this function behaves as if privateKey had been passed to [crypto.createPrivateKey()][]. If it is an object, the padding property can be passed. Otherwise, this function uses RSA_PKCS1_OAEP_PADDING.


最后修改 April 16, 2020: 加密 (a75e592)