Skip to main content
KeyObject.from - node__crypto.d.ts - Node documentation
method KeyObject.from

Usage in Deno

```typescript import { KeyObject } from "node:node__crypto.d.ts"; ```
KeyObject.from(key: webcrypto.CryptoKey): KeyObject
Example: Converting a `CryptoKey` instance to a `KeyObject`: ```js const { KeyObject } = await import('node:crypto'); const { subtle } = globalThis.crypto; const key = await subtle.generateKey({ name: 'HMAC', hash: 'SHA-256', length: 256, }, true, ['sign', 'verify']); const keyObject = KeyObject.from(key); console.log(keyObject.symmetricKeySize); // Prints: 32 (symmetric key size in bytes) ```

Parameters

Return Type