importEncryptedPkcs8PemOrThrow
importEncryptedPkcs8PemOrThrow
Import a private key from PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
When algorithm is omitted, it is inferred from the decrypted key's own privateKeyAlgorithm (see importPkcs8DerOrThrow).
ts
function importEncryptedPkcs8PemOrThrow(
pem: string,
password: string,
algorithm?: PrivateKeyImportInput,
options?: ImportEncryptedKeyOptions,
): Promise<CryptoKey>Parameters
pem:stringpassword:stringalgorithm?:PrivateKeyImportInputoptions?:ImportEncryptedKeyOptions
Examples
ts
const key = await importEncryptedPkcs8PemOrThrow(pem, 'secret', { kind: 'rsa' });
const inferred = await importEncryptedPkcs8PemOrThrow(pem, 'secret');