key algorithm (RSA or EC)
Optional
opt1: string | numberRSA key length or EC curve name (P-{256,384,512}) RSA key length default is 2048 and EC curve name default is "P-256"
Optional
opt2: stringRSA public exponent as hexadecimal string. The default is "010001" (i.e. 65537)
Array of private key PEM and public key PEM
This function generates a RFC 7517 JSON Web Key (JWK) RSA or EC key pair by W3C Web Crypto API.
await generateKeyPairPEM("RSA") ->
["-----BEGIN PRIVATE...", "-----BEGIN PUBLIC..."] // RSA 2048bit and "010001" public exponent
await generateKeyPairPEM("RSA", 4096, "0101") ->
["-----BEGIN PRIVATE...", "-----BEGIN PUBLIC..."] // RSA 4096bit and "0101" public exponent
await generateKeyPairPEM("EC") ->
["-----BEGIN PRIVATE...", "-----BEGIN PUBLIC..."] // P-256 as default
await generateKeyPairPEM("EC", "P-521") ->
["-----BEGIN PRIVATE...", "-----BEGIN PUBLIC..."] // P-521
generate keypair as PEM keys