Skip to main content
webcrypto.SubtleCrypto.generateKey - node__crypto.d.ts - Node documentation
method webcrypto.SubtleCrypto.generateKey

Usage in Deno

```typescript import { type webcrypto } from "node:node__crypto.d.ts"; ```
SubtleCrypto.generateKey(
extractable: boolean,
keyUsages: readonly KeyUsage[],
): Promise<CryptoKeyPair>
Using the method and parameters provided in `algorithm`, `subtle.generateKey()` attempts to generate new keying material. Depending the method used, the method may generate either a single `` or a ``. The `` (public and private key) generating algorithms supported include: - `'RSASSA-PKCS1-v1_5'` - `'RSA-PSS'` - `'RSA-OAEP'` - `'ECDSA'` - `'Ed25519'` - `'Ed448'` - `'ECDH'` - `'X25519'` - `'X448'` The `` (secret key) generating algorithms supported include: - `'HMAC'` - `'AES-CTR'` - `'AES-CBC'` - `'AES-GCM'` - `'AES-KW'`

Parameters

extractable: boolean
keyUsages: readonly KeyUsage[]
See [Key usages](https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages).

Return Type

Promise<CryptoKeyPair>
SubtleCrypto.generateKey(
extractable: boolean,
keyUsages: readonly KeyUsage[],
): Promise<CryptoKey>

Parameters

extractable: boolean
keyUsages: readonly KeyUsage[]

Return Type

Promise<CryptoKey>
SubtleCrypto.generateKey(
extractable: boolean,
keyUsages: KeyUsage[],
): Promise<CryptoKeyPair | CryptoKey>

Parameters

extractable: boolean
keyUsages: KeyUsage[]

Return Type