Node crypto.publicEncrypt function | API Reference | Bun
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
publicEncryptFpublicEncrypt
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
publicEncryptFpublicEncrypt
function
crypto.publicEncryptfunction
publicEncrypt(key:
RsaPublicKey |
RsaPrivateKey |
KeyLike,buffer: string | ArrayBufferViewArrayBufferLike>): NonSharedBuffer;
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.
Referenced typesinterface
RsaPublicKeykey:
KeyLikepadding?: numberinterface
RsaPrivateKeykey:
KeyLikeoaepHash?: string
oaepLabel?: TypedArrayArrayBufferLike>
padding?: number
passphrase?: stringtype
KeyLike = string |
Buffer |
KeyObjectResources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →