mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
1.7 KiB
1.7 KiB
Function: generateKeyPair
💗 Help the project
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.
â–¸ generateKeyPair<T>(alg, options?): Promise<GenerateKeyPairResult<T>>
Generates a private and a public key for a given JWA algorithm identifier. This can only generate
asymmetric key pairs. For symmetric secrets use the generateSecret function.
Note: Under Web Crypto API runtime the privateKey is generated with extractable set to
false by default.
Type parameters
| Name | Type |
|---|---|
T |
extends KeyLike = KeyLike |
Parameters
| Name | Type | Description |
|---|---|---|
alg |
string |
JWA Algorithm Identifier to be used with the generated key pair. |
options? |
GenerateKeyPairOptions |
Additional options passed down to the key pair generation. |
Returns
Promise<GenerateKeyPairResult<T>>
Example
const { publicKey, privateKey } = await jose.generateKeyPair('PS256')
console.log(publicKey)
console.log(privateKey)