Skip to main content
privateEncrypt - node__crypto.d.ts - Node documentation
function privateEncrypt

Usage in Deno

```typescript import { privateEncrypt } from "node:node__crypto.d.ts"; ```
privateEncrypt(
privateKey: RsaPrivateKey | KeyLike,
buffer: ArrayBufferView,
): Buffer
Encrypts `buffer` with `privateKey`. The returned data can be decrypted using the corresponding public key, for example using [publicDecrypt](../.././node__crypto.d.ts/~/publicDecrypt). If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to [createPrivateKey](../.././node__crypto.d.ts/~/createPrivateKey). If it is an object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.

Parameters

privateKey: RsaPrivateKey | KeyLike
buffer: ArrayBufferView

Return Type

Buffer