Skip to content

Variable: keyPair ​

ts
keyPair: object;

Key pair generation functions for creating RSA key pairs.

Type declaration ​

Generate Key Pair ​

generate() ​

ts
generate(): Promise<KeyPair>;

Generates a new 2048-bit RSA key pair and returns it as an object with publicKey and privateKey properties.

Returns ​

Promise<KeyPair>

A Promise that resolves to an object with publicKey and privateKey properties, both as PEM-formatted strings.

Throws ​

Will throw an error if key generation fails.

Example ​
js
const keyPair = await cryptor.keyPair.generate();
console.log(keyPair.publicKey); // Outputs the PEM-formatted public key
console.log(keyPair.privateKey); // Outputs the PEM-formatted private key