crypto.privateEncrypt(privateKey, 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.