crypto.privateDecrypt(privateKey, buffer)
privateKey<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey>oaepHash<string> 用于 OAEP 填充和 MGF1 的哈希函数。 默认值:'sha1'oaepLabel<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> 用于 OAEP 填充的标签。如果未指定,则不使用标签。padding<crypto.constants> 一个可选的填充值,定义在crypto.constants中,可以是:crypto.constants.RSA_NO_PADDING、crypto.constants.RSA_PKCS1_PADDING或crypto.constants.RSA_PKCS1_OAEP_PADDING。
buffer<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>- 返回:<Buffer> 一个包含解密内容的新
Buffer。
使用 privateKey 解密 buffer。buffer 之前是使用对应的公钥加密的,例如使用 crypto.publicEncrypt()。
🌐 Decrypts buffer with privateKey. buffer was previously encrypted using
the corresponding public key, for example using crypto.publicEncrypt().
如果 privateKey 不是 KeyObject,该函数的行为就好像将 privateKey 传递给了 crypto.createPrivateKey()。如果它是一个对象,可以传递 padding 属性。否则,该函数将使用 RSA_PKCS1_OAEP_PADDING。
🌐 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.
在 crypto.privateDecrypt() 中使用 crypto.constants.RSA_PKCS1_PADDING 需要 OpenSSL 支持隐式拒绝(rsa_pkcs1_implicit_rejection)。如果 Node.js 使用的 OpenSSL 版本不支持此功能,尝试使用 RSA_PKCS1_PADDING 将会失败。
🌐 Using crypto.constants.RSA_PKCS1_PADDING in crypto.privateDecrypt()
requires OpenSSL to support implicit rejection (rsa_pkcs1_implicit_rejection).
If the version of OpenSSL used by Node.js does not support this feature,
attempting to use RSA_PKCS1_PADDING will fail.