Skip to main content
Module

x/jose/index.ts>generateSecret

"JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS with no dependencies using runtime's native crypto in Node.js, Browser, Cloudflare Workers, Electron, and Deno.
Extremely Popular
Go to Latest
function generateSecret
import { generateSecret } from "https://deno.land/x/jose@v4.8.3/index.ts";

Generates a symmetric secret key for a given JWA algorithm identifier.

Note: Under Web Cryptography API runtime the secret key is generated with extractable set to false by default.

Examples

Usage

const secret = await jose.generateSecret('HS256')
console.log(secret)

Parameters

alg: string

JWA Algorithm Identifier to be used with the generated secret.

optional
options: GenerateSecretOptions

Additional options passed down to the secret generation.

Returns

Promise<KeyLike | Uint8Array>