Skip to main content
generateKeyPair - crypto - Node documentation
function generateKeyPair

Usage in Deno

import { generateKeyPair } from "node:crypto";
generateKeyPair(
type: "rsa",
options: RSAKeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Generates a new asymmetric key pair of the given type. RSA, RSA-PSS, DSA, EC, Ed25519, Ed448, X25519, X448, and DH are currently supported.

If a publicKeyEncoding or privateKeyEncoding was specified, this function behaves as if keyObject.export() had been called on its result. Otherwise, the respective part of the key is returned as a KeyObject.

It is recommended to encode public keys as 'spki' and private keys as 'pkcs8' with encryption for long-term storage:

const {
  generateKeyPair,
} = await import('node:crypto');

generateKeyPair('rsa', {
  modulusLength: 4096,
  publicKeyEncoding: {
    type: 'spki',
    format: 'pem',
  },
  privateKeyEncoding: {
    type: 'pkcs8',
    format: 'pem',
    cipher: 'aes-256-cbc',
    passphrase: 'top secret',
  },
}, (err, publicKey, privateKey) => {
  // Handle errors and use the generated key pair.
});

On completion, callback will be called with err set to undefined and publicKey / privateKey representing the generated key pair.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with publicKey and privateKey properties.

Parameters

type: "rsa"

Must be 'rsa', 'rsa-pss', 'dsa', 'ec', 'ed25519', 'ed448', 'x25519', 'x448', or 'dh'.

options: RSAKeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "rsa",
options: RSAKeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa"
options: RSAKeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "rsa",
options: RSAKeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa"
options: RSAKeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "rsa",
options: RSAKeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa"
options: RSAKeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "rsa",
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa"
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "rsa-pss",
options: RSAPSSKeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa-pss"
options: RSAPSSKeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "rsa-pss",
options: RSAPSSKeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa-pss"
options: RSAPSSKeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "rsa-pss",
options: RSAPSSKeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa-pss"
options: RSAPSSKeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "rsa-pss",
options: RSAPSSKeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa-pss"
options: RSAPSSKeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "rsa-pss",
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "rsa-pss"
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "dsa",
options: DSAKeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "dsa"
options: DSAKeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "dsa",
options: DSAKeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "dsa"
options: DSAKeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "dsa",
options: DSAKeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "dsa"
options: DSAKeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "dsa",
options: DSAKeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "dsa"
options: DSAKeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "dsa",
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "dsa"
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "ec",
options: ECKeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ec"
options: ECKeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ec",
options: ECKeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ec"
options: ECKeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ec",
options: ECKeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ec"
options: ECKeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ec",
options: ECKeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ec"
options: ECKeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ec",
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ec"
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "ed25519",
options: ED25519KeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed25519"
options: ED25519KeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ed25519",
options: ED25519KeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed25519"
options: ED25519KeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ed25519",
options: ED25519KeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed25519"
options: ED25519KeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ed25519",
options: ED25519KeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed25519"
options: ED25519KeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ed25519",
options: ED25519KeyPairKeyObjectOptions | undefined,
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed25519"
options: ED25519KeyPairKeyObjectOptions | undefined
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "ed448",
options: ED448KeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed448"
options: ED448KeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ed448",
options: ED448KeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed448"
options: ED448KeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ed448",
options: ED448KeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed448"
options: ED448KeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "ed448",
options: ED448KeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed448"
options: ED448KeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "ed448",
options: ED448KeyPairKeyObjectOptions | undefined,
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "ed448"
options: ED448KeyPairKeyObjectOptions | undefined
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "x25519",
options: X25519KeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x25519"
options: X25519KeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "x25519",
options: X25519KeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x25519"
options: X25519KeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "x25519",
options: X25519KeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x25519"
options: X25519KeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "x25519",
options: X25519KeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x25519"
options: X25519KeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "x25519",
options: X25519KeyPairKeyObjectOptions | undefined,
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x25519"
options: X25519KeyPairKeyObjectOptions | undefined
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void
generateKeyPair(
type: "x448",
options: X448KeyPairOptions<"pem", "pem">,
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x448"
options: X448KeyPairOptions<"pem", "pem">
callback: (
err: Error | null,
publicKey: string,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "x448",
options: X448KeyPairOptions<"pem", "der">,
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x448"
options: X448KeyPairOptions<"pem", "der">
callback: (
err: Error | null,
publicKey: string,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "x448",
options: X448KeyPairOptions<"der", "pem">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x448"
options: X448KeyPairOptions<"der", "pem">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: string,
) => void

Return Type

void
generateKeyPair(
type: "x448",
options: X448KeyPairOptions<"der", "der">,
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x448"
options: X448KeyPairOptions<"der", "der">
callback: (
err: Error | null,
publicKey: Buffer,
privateKey: Buffer,
) => void

Return Type

void
generateKeyPair(
type: "x448",
options: X448KeyPairKeyObjectOptions | undefined,
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void
,
): void
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> The <code>x448</code> option is not supported.</p> </div></div>

Parameters

type: "x448"
options: X448KeyPairKeyObjectOptions | undefined
callback: (
err: Error | null,
publicKey: KeyObject,
privateKey: KeyObject,
) => void

Return Type

void