exportPkcs8Pem
Export a private key as PEM-encoded PKCS#8 PrivateKeyInfo.
ts
function exportPkcs8Pem(
privateKey: CryptoKey,
): Promise<string>Parameters
privateKey:CryptoKey
See also
importPkcs8Pemfor the inverse operationexportEncryptedPkcs8Pemfor password-protected export
Examples
ts
const keys = await generateKeyPair();
const pem = await exportPkcs8Pem(keys.privateKey);
// -----BEGIN PRIVATE KEY-----
// MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEH...
// -----END PRIVATE KEY-----