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

Usage in Deno

```typescript import { type webcrypto } from "node:node__crypto.d.ts"; ```
SubtleCrypto.exportKey(
format: "jwk",
key: CryptoKey,
): Promise<JsonWebKey>
Exports the given key into the specified format, if supported. If the `` is not extractable, the returned promise will reject. When `format` is either `'pkcs8'` or `'spki'` and the export is successful, the returned promise will be resolved with an `` containing the exported key data. When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a JavaScript object conforming to the [JSON Web Key](https://tools.ietf.org/html/rfc7517) specification.

Parameters

format: "jwk"
Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.

Return Type

Promise<JsonWebKey>
`` containing ``.
SubtleCrypto.exportKey(
format: Exclude<KeyFormat, "jwk">,
key: CryptoKey,
): Promise<ArrayBuffer>

Parameters

format: Exclude<KeyFormat, "jwk">

Return Type

Promise<ArrayBuffer>