crypto.privateEncrypt(privateKey, buffer)
privateKey<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey>key<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey> PEM 编码的私钥。passphrase<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> 可选的私钥密码。padding<crypto.constants>crypto.constants中定义的可选填充值,可以是:crypto.constants.RSA_NO_PADDING或crypto.constants.RSA_PKCS1_PADDING。encoding<string> 当buffer、key或passphrase是字符串时使用的字符串编码。
buffer<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>- 返回: <Buffer> 带有加密内容的新
Buffer。
用 privateKey 加密 buffer。
返回的数据可以使用相应的公钥解密,例如使用 crypto.publicDecrypt()。
如果 privateKey 不是 KeyObject,则此函数的行为就像将 privateKey 传给 crypto.createPrivateKey() 一样。
如果是对象,则可以传入 padding 属性。
否则,该函数使用 RSA_PKCS1_PADDING。
privateKey<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey>key<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> | <CryptoKey> A PEM encoded private key.passphrase<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> An optional passphrase for the private key.padding<crypto.constants> An optional padding value defined incrypto.constants, which may be:crypto.constants.RSA_NO_PADDINGorcrypto.constants.RSA_PKCS1_PADDING.encoding<string> The string encoding to use whenbuffer,key, orpassphraseare strings.
buffer<string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>- Returns: <Buffer> A new
Bufferwith the encrypted content.
Encrypts buffer with privateKey. The returned data can be decrypted using
the corresponding public key, for example using crypto.publicDecrypt().
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_PADDING.