Encrypts the content of buffer with key and returns a new Buffer with encrypted content. The returned data can be decrypted using
the corresponding private key, for example using privateDecrypt.
If key is not a KeyObject, this function behaves as if key had been passed to createPublicKey. If it is an
object, the padding property can be passed. Otherwise, this function uses RSA_PKCS1_OAEP_PADDING.
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
Encrypts the content of
buffer
withkey
and returns a newBuffer
with encrypted content. The returned data can be decrypted using the corresponding private key, for example using privateDecrypt.If
key
is not aKeyObject
, this function behaves as ifkey
had been passed to createPublicKey. If it is an object, thepadding
property can be passed. Otherwise, this function usesRSA_PKCS1_OAEP_PADDING
.Because RSA public keys can be derived from private keys, a private key may be passed instead of a public key.