diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9088b78babdadb..dfe49afa497781 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -53,7 +53,7 @@ The `crypto` module provides the `Certificate` class for working with SPKAC data. The most common usage is handling output generated by the HTML5 `` element. Node.js uses [OpenSSL's SPKAC implementation][] internally. -### `Certificate.exportChallenge(spkac[, encoding])` +### Static method: `Certificate.exportChallenge(spkac[, encoding])` + +* `key` {CryptoKey} +* Returns: {KeyObject} + +Example: Converting a `CryptoKey` instance to a `KeyObject`: + +```js +const { webcrypto: { subtle }, KeyObject } = require('crypto'); + +(async function() { + 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) +})(); +``` + ### `keyObject.asymmetricKeyDetails`