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()。
【Encrypts buffer with privateKey. The returned data can be decrypted using
the corresponding public key, for example using crypto.publicDecrypt().】
如果 privateKey 不是 KeyObject,此函数的行为就好像将 privateKey 传递给了 crypto.createPrivateKey()。如果它是一个对象,可以传入 padding 属性。否则,此函数将使用 RSA_PKCS1_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_PADDING.】