mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
1.6 KiB
1.6 KiB
Function: generateSecret
💗 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.
â–¸ generateSecret<T>(alg, options?): Promise<T | Uint8Array>
Generates a symmetric secret key for a given JWA algorithm identifier.
Note: Under Web Crypto API runtime the secret key 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 secret. |
options? |
GenerateSecretOptions |
Additional options passed down to the secret generation. |
Returns
Promise<T | Uint8Array>
Example
const secret = await jose.generateSecret('HS256')
console.log(secret)