Web Crypto

subtle.importKey()

Builds a CryptoKey from existing key material. The fixed bytes below are synthetic and must not be used as a real secret. Tested on Node.js 22.16.0. Example output (one line per entry): ["HMAC sign false"].

Formal Syntax & Structure

nodejs syntaxnodejs
subtle.importKey(format, keyData, algorithm, extractable, keyUsages)

Parameters & Attributes

NameTypeDescription
formatstringKey format.
keyDataBufferSource | objectEncoded key material.
algorithmstring | objectKey algorithm.
extractablebooleanExport permission.
keyUsagesstring[]Allowed operations.

Return Value

Promise<CryptoKey>

Imported key.

Working Example

Example Snippetnodejs
import { webcrypto as crypto } from 'node:crypto';const k = await crypto.subtle.importKey('raw', new Uint8Array(32).fill(7), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);console.log(k.algorithm.name, k.usages.join(','), k.extractable);
Node.js Reference