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()
。
如果 privateKey
不是 KeyObject
,则此函数的行为就像将 privateKey
传给 crypto.createPrivateKey()
一样。
如果是对象,则可以传入 padding
属性。
否则,该函数使用 RSA_PKCS1_OAEP_PADDING
。
privateKey
<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey>oaepHash
<string> The hash function to use for OAEP padding and MGF1. Default:'sha1'
oaepLabel
<string> | <ArrayBuffer> | <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 incrypto.constants
, which may be:crypto.constants.RSA_NO_PADDING
,crypto.constants.RSA_PKCS1_PADDING
, orcrypto.constants.RSA_PKCS1_OAEP_PADDING
.
buffer
<string> | <ArrayBuffer> | <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
.