{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"crypto","path":"/crypto","type":"module","module":"crypto","title":"Crypto","introducedIn":"v0.3.6","sourceLink":{"path":"lib/crypto.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/crypto.js"},"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:crypto` module provides cryptographic functionality that includes a\nset of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify\nfunctions.\n\n```mjs\nconst { createHmac } = await import('node:crypto');\n\nconst secret = 'abcdefg';\nconst hash = createHmac('sha256', secret)\n               .update('I love cupcakes')\n               .digest('hex');\nconsole.log(hash);\n// Prints:\n//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e\n```\n\n```cjs\nconst { createHmac } = require('node:crypto');\n\nconst secret = 'abcdefg';\nconst hash = createHmac('sha256', secret)\n               .update('I love cupcakes')\n               .digest('hex');\nconsole.log(hash);\n// Prints:\n//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e\n```","summary":"The `node:crypto` module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.","examples":[{"language":"mjs","displayName":null,"code":"const { createHmac } = await import('node:crypto');\n\nconst secret = 'abcdefg';\nconst hash = createHmac('sha256', secret)\n               .update('I love cupcakes')\n               .digest('hex');\nconsole.log(hash);\n// Prints:\n//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e"},{"language":"cjs","displayName":null,"code":"const { createHmac } = require('node:crypto');\n\nconst secret = 'abcdefg';\nconst hash = createHmac('sha256', secret)\n               .update('I love cupcakes')\n               .digest('hex');\nconsole.log(hash);\n// Prints:\n//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e"}],"children":[{"kind":"section","id":"determining-if-crypto-support-is-unavailable","name":"Determining if crypto support is unavailable","title":"Determining if crypto support is unavailable","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"It is possible for Node.js to be built without including support for the\n`node:crypto` module. In such cases, attempting to `import` from `crypto` or\ncalling `require('node:crypto')` will result in an error being thrown.\n\nWhen using CommonJS, the error thrown can be caught using try/catch:\n\n```cjs\nlet crypto;\ntry {\n  crypto = require('node:crypto');\n} catch (err) {\n  console.error('crypto support is disabled!');\n}\n```\n\nWhen using the lexical ESM `import` keyword, the error can only be\ncaught if a handler for `process.on('uncaughtException')` is registered\n*before* any attempt to load the module is made (using, for instance,\na preload module).\n\nWhen using ESM, if there is a chance that the code may be run on a build\nof Node.js where crypto support is not enabled, consider using the\n[`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) function instead of the lexical `import` keyword:\n\n```mjs\nlet crypto;\ntry {\n  crypto = await import('node:crypto');\n} catch (err) {\n  console.error('crypto support is disabled!');\n}\n```","summary":"It is possible for Node.js to be built without including support for the `node:crypto` module. In such cases, attempting to `import` from `crypto` or calling `require('node:crypto')` will result in an error being thrown.","examples":[{"language":"cjs","displayName":null,"code":"let crypto;\ntry {\n  crypto = require('node:crypto');\n} catch (err) {\n  console.error('crypto support is disabled!');\n}"},{"language":"mjs","displayName":null,"code":"let crypto;\ntry {\n  crypto = await import('node:crypto');\n} catch (err) {\n  console.error('crypto support is disabled!');\n}"}],"children":[]},{"kind":"section","id":"asymmetric-key-types","name":"Asymmetric key types","title":"Asymmetric key types","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following lists group the asymmetric key types recognized by the\n[`KeyObject`](#class-keyobject) API by the complete set of formats supported for importing and\nexporting each type.\n\n**Formats:** `'pem'`, `'der'`\n\n* **`'dh'` (Diffie-Hellman)** — OID `1.2.840.113549.1.3.1`\n* **`'dsa'`** — OID `1.2.840.10040.4.1`\n* **`'rsa-pss'`** — OID `1.2.840.113549.1.1.10`\n\n**Formats:** `'pem'`, `'der'`, `'jwk'`\n\n* **`'rsa'`** — OID `1.2.840.113549.1.1.1`\n\n**Formats:** `'pem'`, `'der'`, `'jwk'`, `'raw-public'`, `'raw-private'`\n\n* **`'ec'` (Elliptic curve)** — OID `1.2.840.10045.2.1`\n* **`'ed25519'`** — OID `1.3.101.112`\n* **`'ed448'`** — OID `1.3.101.113`\n* **`'slh-dsa-sha2-128f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.21`\n* **`'slh-dsa-sha2-128s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.20`\n* **`'slh-dsa-sha2-192f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.23`\n* **`'slh-dsa-sha2-192s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.22`\n* **`'slh-dsa-sha2-256f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.25`\n* **`'slh-dsa-sha2-256s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.24`\n* **`'slh-dsa-shake-128f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.27`\n* **`'slh-dsa-shake-128s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.26`\n* **`'slh-dsa-shake-192f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.29`\n* **`'slh-dsa-shake-192s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.28`\n* **`'slh-dsa-shake-256f'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.31`\n* **`'slh-dsa-shake-256s'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.30`\n* **`'x25519'`** — OID `1.3.101.110`\n* **`'x448'`** — OID `1.3.101.111`\n\n**Formats:** `'pem'`, `'der'`, `'jwk'`, `'raw-public'`, `'raw-seed'`\n\n* **`'ml-dsa-44'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.17`\n* **`'ml-dsa-65'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.18`\n* **`'ml-dsa-87'`[^openssl35]** — OID `2.16.840.1.101.3.4.3.19`\n* **`'ml-kem-512'`[^openssl35]** — OID `2.16.840.1.101.3.4.4.1`\n* **`'ml-kem-768'`[^openssl35]** — OID `2.16.840.1.101.3.4.4.2`\n* **`'ml-kem-1024'`[^openssl35]** — OID `2.16.840.1.101.3.4.4.3`","summary":"The following lists group the asymmetric key types recognized by the `KeyObject` API by the complete set of formats supported for importing and exporting each type.","examples":[],"children":[{"kind":"section","id":"key-formats","name":"Key formats","title":"Key formats","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Asymmetric keys can be represented in several formats. **The recommended\napproach is to import key material into a [`KeyObject`](#class-keyobject) once and reuse it**\nfor all subsequent operations, as this avoids repeated parsing and delivers\nthe best performance.\n\nWhen a [`KeyObject`](#class-keyobject) is not practical - for example, when key material\narrives in a protocol message and is used only once - most cryptographic\nfunctions also accept a PEM string or an object specifying the format\nand key material directly. See [`crypto.createPublicKey()`](#cryptocreatepublickeykey),\n[`crypto.createPrivateKey()`](#cryptocreateprivatekeykey), and [`keyObject.export()`](#keyobjectexportoptions) for the full\noptions accepted by each format.","summary":"Asymmetric keys can be represented in several formats. **The recommended approach is to import key material into a `KeyObject` once and reuse it** for all subsequent operations, as this avoids repeated parsing and delivers the best performance.","examples":[],"children":[{"kind":"section","id":"keyobject","name":"KeyObject","title":"KeyObject","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A [`KeyObject`](#class-keyobject) is the in-memory representation of a parsed key. It is\ncreated by [`crypto.createPublicKey()`](#cryptocreatepublickeykey), [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey),\n[`crypto.createSecretKey()`](#cryptocreatesecretkeykey-encoding), or key generation functions such as\n[`crypto.generateKeyPair()`](#cryptogeneratekeypairtype-options-callback). The first cryptographic operation with a given\n[`KeyObject`](#class-keyobject) may be slower than subsequent ones because OpenSSL lazily\ninitializes internal caches on first use.","summary":"A `KeyObject` is the in-memory representation of a parsed key. It is created by `crypto.createPublicKey()`, `crypto.createPrivateKey()`, `crypto.createSecretKey()`, or key generation functions such as `crypto.generateKeyPair()`. The first cryptographic operation with a given `KeyObject` may be slower than subsequent ones because OpenSSL lazily initializes internal caches on first use.","examples":[],"children":[]},{"kind":"section","id":"pem-and-der","name":"PEM and DER","title":"PEM and DER","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"PEM and DER are the traditional encoding formats for asymmetric keys based on\nASN.1 structures.\n\n* **PEM** is a text encoding that wraps Base64-encoded DER data between\n  header and footer lines (e.g. `-----BEGIN PUBLIC KEY-----`). PEM strings can\n  be passed directly to most cryptographic operations.\n* **DER** is the binary encoding of the same ASN.1 structures. When providing\n  DER input, the `type` (typically `'spki'` or `'pkcs8'`) must be specified\n  explicitly.","summary":"PEM and DER are the traditional encoding formats for asymmetric keys based on ASN.1 structures.","examples":[],"children":[]},{"kind":"section","id":"json-web-key-jwk","name":"JSON Web Key (JWK)","title":"JSON Web Key (JWK)","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"JSON Web Key (JWK) is a JSON-based key representation defined in\n[RFC 7517](https://www.rfc-editor.org/rfc/rfc7517.txt). JWK encodes each key component as an individual Base64url-encoded\nvalue inside a JSON object. For RSA keys, JWK avoids ASN.1 parsing overhead\nand is the fastest serialized import format.","summary":"JSON Web Key (JWK) is a JSON-based key representation defined in RFC 7517. JWK encodes each key component as an individual Base64url-encoded value inside a JSON object. For RSA keys, JWK avoids ASN.1 parsing overhead and is the fastest serialized import format.","examples":[],"children":[]},{"kind":"section","id":"raw-key-formats","name":"Raw key formats","title":"Raw key formats","scope":"module","overloadOf":null,"stability":{"index":"1.1","description":"Active development"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `'raw-public'`, `'raw-private'`, and `'raw-seed'` key formats allow\nimporting and exporting raw key material without any encoding wrapper.\nSee [`keyObject.export()`](#keyobjectexportoptions), [`crypto.createPublicKey()`](#cryptocreatepublickeykey), and\n[`crypto.createPrivateKey()`](#cryptocreateprivatekeykey) for usage details.\n\n`'raw-public'` is generally the fastest way to import a public key.\n`'raw-private'` and `'raw-seed'` are not always faster than other formats\nbecause they only contain the private scalar or seed - importing them requires\nderiving the public key component (e.g. elliptic curve point multiplication or\nseed expansion), which can be expensive. Other formats include both private\nand public components, avoiding that computation.","summary":"The `'raw-public'`, `'raw-private'`, and `'raw-seed'` key formats allow importing and exporting raw key material without any encoding wrapper. See `keyObject.export()`, `crypto.createPublicKey()`, and `crypto.createPrivateKey()` for usage details.","examples":[],"children":[]}]},{"kind":"section","id":"choosing-a-key-format","name":"Choosing a key format","title":"Choosing a key format","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"**Always prefer a [`KeyObject`](#class-keyobject)** - create one from whatever format you\nhave and reuse it. The guidance below applies only when choosing between\nserialization formats, either for importing into a [`KeyObject`](#class-keyobject) or for\npassing key material inline when a [`KeyObject`](#class-keyobject) is not practical.","summary":"**Always prefer a `KeyObject`** - create one from whatever format you have and reuse it. The guidance below applies only when choosing between serialization formats, either for importing into a `KeyObject` or for passing key material inline when a `KeyObject` is not practical.","examples":[],"children":[{"kind":"section","id":"importing-keys","name":"Importing keys","title":"Importing keys","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When creating a [`KeyObject`](#class-keyobject) for repeated use, the import cost is paid once,\nso choosing a faster format reduces startup latency.\n\nThe import cost breaks down into two parts: **parsing overhead** (decoding the\nserialization wrapper) and **key computation** (any mathematical work needed to\nreconstruct the full key, such as deriving a public key from a private scalar\nor expanding a seed). Which part dominates depends on the key type. For\nexample:\n\n* Public keys - `'raw-public'` is the fastest serialized format because the\n  raw format skips all ASN.1 and Base64 decoding.\n* EC private keys - `'raw-private'` is faster than PEM or DER because it\n  avoids ASN.1 parsing. However, for larger curves (e.g. P-384, P-521) the\n  required derivation of the public point from the private scalar becomes\n  expensive, reducing the advantage.\n* RSA keys - `'jwk'` is the fastest serialized format. JWK represents RSA\n  key components as individual Base64url-encoded integers, avoiding the\n  overhead of ASN.1 parsing entirely.","summary":"When creating a `KeyObject` for repeated use, the import cost is paid once, so choosing a faster format reduces startup latency.","examples":[],"children":[]},{"kind":"section","id":"inline-key-material-in-operations","name":"Inline key material in operations","title":"Inline key material in operations","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When a [`KeyObject`](#class-keyobject) cannot be reused (e.g. the key arrives as raw bytes in\na protocol message and is used only once), most cryptographic functions also\naccept a PEM string or an object specifying the format and key\nmaterial directly. In this case the total cost is the sum of key import and\nthe cryptographic computation itself.\n\nFor operations where the cryptographic computation dominates - such as\nsigning with RSA or ECDH key agreement with P-384 or P-521 - the\nserialization format has negligible impact on overall throughput, so choose\nwhichever format is most convenient. For lightweight operations like Ed25519\nsigning or verification, the import cost is a larger fraction of the total,\nso a faster format like `'raw-public'` or `'raw-private'` can meaningfully\nimprove throughput.\n\nEven if the same key material is used only a few times, it is worth importing it\ninto a [`KeyObject`](#class-keyobject) rather than passing the raw or PEM representation\nrepeatedly.","summary":"When a `KeyObject` cannot be reused (e.g. the key arrives as raw bytes in a protocol message and is used only once), most cryptographic functions also accept a PEM string or an object specifying the format and key material directly. In this case the total cost is the sum of key import and the cryptographic computation itself.","examples":[],"children":[]}]},{"kind":"section","id":"examples","name":"Examples","title":"Examples","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Example: Reusing a [`KeyObject`](#class-keyobject) across sign and verify operations:\n\n```mjs\nimport { promisify } from 'node:util';\nconst { generateKeyPair, sign, verify } = await import('node:crypto');\n\nconst { publicKey, privateKey } = await promisify(generateKeyPair)('ed25519');\n\n// A KeyObject holds the parsed key in memory and can be reused\n// across multiple operations without re-parsing.\nconst data = new TextEncoder().encode('message to sign');\nconst signature = sign(null, data, privateKey);\nverify(null, data, publicKey, signature);\n```\n\nExample: Importing keys of various formats into [`KeyObject`](#class-keyobject)s:\n\n```mjs\nimport { promisify } from 'node:util';\nconst {\n  createPrivateKey, createPublicKey, generateKeyPair,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ed25519');\n\n// PEM\nconst privatePem = generated.privateKey.export({ format: 'pem', type: 'pkcs8' });\nconst publicPem = generated.publicKey.export({ format: 'pem', type: 'spki' });\ncreatePrivateKey(privatePem);\ncreatePublicKey(publicPem);\n\n// DER - requires explicit type\nconst privateDer = generated.privateKey.export({ format: 'der', type: 'pkcs8' });\nconst publicDer = generated.publicKey.export({ format: 'der', type: 'spki' });\ncreatePrivateKey({ key: privateDer, format: 'der', type: 'pkcs8' });\ncreatePublicKey({ key: publicDer, format: 'der', type: 'spki' });\n\n// JWK\nconst privateJwk = generated.privateKey.export({ format: 'jwk' });\nconst publicJwk = generated.publicKey.export({ format: 'jwk' });\ncreatePrivateKey({ key: privateJwk, format: 'jwk' });\ncreatePublicKey({ key: publicJwk, format: 'jwk' });\n\n// Raw\nconst rawPriv = generated.privateKey.export({ format: 'raw-private' });\nconst rawPub = generated.publicKey.export({ format: 'raw-public' });\ncreatePrivateKey({ key: rawPriv, format: 'raw-private', asymmetricKeyType: 'ed25519' });\ncreatePublicKey({ key: rawPub, format: 'raw-public', asymmetricKeyType: 'ed25519' });\n```\n\nExample: Passing key material directly to [`crypto.sign()`](#cryptosignalgorithm-data-key-callback) and\n[`crypto.verify()`](#cryptoverifyalgorithm-data-key-signature-callback) without creating a [`KeyObject`](#class-keyobject) first:\n\n```mjs\nimport { promisify } from 'node:util';\nconst { generateKeyPair, sign, verify } = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ed25519');\n\nconst data = new TextEncoder().encode('message to sign');\n\n// PEM strings\nconst privatePem = generated.privateKey.export({ format: 'pem', type: 'pkcs8' });\nconst publicPem = generated.publicKey.export({ format: 'pem', type: 'spki' });\nconst sig1 = sign(null, data, privatePem);\nverify(null, data, publicPem, sig1);\n\n// JWK objects\nconst privateJwk = generated.privateKey.export({ format: 'jwk' });\nconst publicJwk = generated.publicKey.export({ format: 'jwk' });\nconst sig2 = sign(null, data, { key: privateJwk, format: 'jwk' });\nverify(null, data, { key: publicJwk, format: 'jwk' }, sig2);\n\n// Raw key bytes\nconst rawPriv = generated.privateKey.export({ format: 'raw-private' });\nconst rawPub = generated.publicKey.export({ format: 'raw-public' });\nconst sig3 = sign(null, data, {\n  key: rawPriv, format: 'raw-private', asymmetricKeyType: 'ed25519',\n});\nverify(null, data, {\n  key: rawPub, format: 'raw-public', asymmetricKeyType: 'ed25519',\n}, sig3);\n```\n\nExample: For EC keys, the `namedCurve` option is required when importing\nraw keys:\n\n```mjs\nimport { promisify } from 'node:util';\nconst {\n  createPrivateKey, createPublicKey, generateKeyPair, sign, verify,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ec', {\n  namedCurve: 'P-256',\n});\n\n// Export the raw EC public key (uncompressed by default).\nconst rawPublicKey = generated.publicKey.export({ format: 'raw-public' });\n\n// The following is equivalent.\nconst rawPublicKeyUncompressed = generated.publicKey.export({\n  format: 'raw-public',\n  type: 'uncompressed',\n});\n\n// Export compressed point format.\nconst rawPublicKeyCompressed = generated.publicKey.export({\n  format: 'raw-public',\n  type: 'compressed',\n});\n\n// Export the raw EC private key.\nconst rawPrivateKey = generated.privateKey.export({ format: 'raw-private' });\n\n// Import the raw EC keys.\n// Both compressed and uncompressed point formats are accepted.\nconst publicKey = createPublicKey({\n  key: rawPublicKey,\n  format: 'raw-public',\n  asymmetricKeyType: 'ec',\n  namedCurve: 'P-256',\n});\nconst privateKey = createPrivateKey({\n  key: rawPrivateKey,\n  format: 'raw-private',\n  asymmetricKeyType: 'ec',\n  namedCurve: 'P-256',\n});\n\nconst data = new TextEncoder().encode('message to sign');\nconst signature = sign('sha256', data, privateKey);\nverify('sha256', data, publicKey, signature);\n```\n\nExample: Exporting raw seeds and importing them:\n\n```mjs\nimport { promisify } from 'node:util';\nconst {\n  createPrivateKey, decapsulate, encapsulate, generateKeyPair,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ml-kem-768');\n\n// Export the raw seed (64 bytes for ML-KEM).\nconst seed = generated.privateKey.export({ format: 'raw-seed' });\n\n// Import the raw seed.\nconst privateKey = createPrivateKey({\n  key: seed,\n  format: 'raw-seed',\n  asymmetricKeyType: 'ml-kem-768',\n});\n\nconst { ciphertext } = encapsulate(generated.publicKey);\ndecapsulate(privateKey, ciphertext);\n```","summary":"Example: Reusing a `KeyObject` across sign and verify operations:","examples":[{"language":"mjs","displayName":null,"code":"import { promisify } from 'node:util';\nconst { generateKeyPair, sign, verify } = await import('node:crypto');\n\nconst { publicKey, privateKey } = await promisify(generateKeyPair)('ed25519');\n\n// A KeyObject holds the parsed key in memory and can be reused\n// across multiple operations without re-parsing.\nconst data = new TextEncoder().encode('message to sign');\nconst signature = sign(null, data, privateKey);\nverify(null, data, publicKey, signature);"},{"language":"mjs","displayName":null,"code":"import { promisify } from 'node:util';\nconst {\n  createPrivateKey, createPublicKey, generateKeyPair,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ed25519');\n\n// PEM\nconst privatePem = generated.privateKey.export({ format: 'pem', type: 'pkcs8' });\nconst publicPem = generated.publicKey.export({ format: 'pem', type: 'spki' });\ncreatePrivateKey(privatePem);\ncreatePublicKey(publicPem);\n\n// DER - requires explicit type\nconst privateDer = generated.privateKey.export({ format: 'der', type: 'pkcs8' });\nconst publicDer = generated.publicKey.export({ format: 'der', type: 'spki' });\ncreatePrivateKey({ key: privateDer, format: 'der', type: 'pkcs8' });\ncreatePublicKey({ key: publicDer, format: 'der', type: 'spki' });\n\n// JWK\nconst privateJwk = generated.privateKey.export({ format: 'jwk' });\nconst publicJwk = generated.publicKey.export({ format: 'jwk' });\ncreatePrivateKey({ key: privateJwk, format: 'jwk' });\ncreatePublicKey({ key: publicJwk, format: 'jwk' });\n\n// Raw\nconst rawPriv = generated.privateKey.export({ format: 'raw-private' });\nconst rawPub = generated.publicKey.export({ format: 'raw-public' });\ncreatePrivateKey({ key: rawPriv, format: 'raw-private', asymmetricKeyType: 'ed25519' });\ncreatePublicKey({ key: rawPub, format: 'raw-public', asymmetricKeyType: 'ed25519' });"},{"language":"mjs","displayName":null,"code":"import { promisify } from 'node:util';\nconst { generateKeyPair, sign, verify } = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ed25519');\n\nconst data = new TextEncoder().encode('message to sign');\n\n// PEM strings\nconst privatePem = generated.privateKey.export({ format: 'pem', type: 'pkcs8' });\nconst publicPem = generated.publicKey.export({ format: 'pem', type: 'spki' });\nconst sig1 = sign(null, data, privatePem);\nverify(null, data, publicPem, sig1);\n\n// JWK objects\nconst privateJwk = generated.privateKey.export({ format: 'jwk' });\nconst publicJwk = generated.publicKey.export({ format: 'jwk' });\nconst sig2 = sign(null, data, { key: privateJwk, format: 'jwk' });\nverify(null, data, { key: publicJwk, format: 'jwk' }, sig2);\n\n// Raw key bytes\nconst rawPriv = generated.privateKey.export({ format: 'raw-private' });\nconst rawPub = generated.publicKey.export({ format: 'raw-public' });\nconst sig3 = sign(null, data, {\n  key: rawPriv, format: 'raw-private', asymmetricKeyType: 'ed25519',\n});\nverify(null, data, {\n  key: rawPub, format: 'raw-public', asymmetricKeyType: 'ed25519',\n}, sig3);"},{"language":"mjs","displayName":null,"code":"import { promisify } from 'node:util';\nconst {\n  createPrivateKey, createPublicKey, generateKeyPair, sign, verify,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ec', {\n  namedCurve: 'P-256',\n});\n\n// Export the raw EC public key (uncompressed by default).\nconst rawPublicKey = generated.publicKey.export({ format: 'raw-public' });\n\n// The following is equivalent.\nconst rawPublicKeyUncompressed = generated.publicKey.export({\n  format: 'raw-public',\n  type: 'uncompressed',\n});\n\n// Export compressed point format.\nconst rawPublicKeyCompressed = generated.publicKey.export({\n  format: 'raw-public',\n  type: 'compressed',\n});\n\n// Export the raw EC private key.\nconst rawPrivateKey = generated.privateKey.export({ format: 'raw-private' });\n\n// Import the raw EC keys.\n// Both compressed and uncompressed point formats are accepted.\nconst publicKey = createPublicKey({\n  key: rawPublicKey,\n  format: 'raw-public',\n  asymmetricKeyType: 'ec',\n  namedCurve: 'P-256',\n});\nconst privateKey = createPrivateKey({\n  key: rawPrivateKey,\n  format: 'raw-private',\n  asymmetricKeyType: 'ec',\n  namedCurve: 'P-256',\n});\n\nconst data = new TextEncoder().encode('message to sign');\nconst signature = sign('sha256', data, privateKey);\nverify('sha256', data, publicKey, signature);"},{"language":"mjs","displayName":null,"code":"import { promisify } from 'node:util';\nconst {\n  createPrivateKey, decapsulate, encapsulate, generateKeyPair,\n} = await import('node:crypto');\n\nconst generated = await promisify(generateKeyPair)('ml-kem-768');\n\n// Export the raw seed (64 bytes for ML-KEM).\nconst seed = generated.privateKey.export({ format: 'raw-seed' });\n\n// Import the raw seed.\nconst privateKey = createPrivateKey({\n  key: seed,\n  format: 'raw-seed',\n  asymmetricKeyType: 'ml-kem-768',\n});\n\nconst { ciphertext } = encapsulate(generated.publicKey);\ndecapsulate(privateKey, ciphertext);"}],"children":[]}]},{"kind":"class","id":"class-certificate","name":"Certificate","title":"Class: `Certificate`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"SPKAC is a Certificate Signing Request mechanism originally implemented by\nNetscape and was specified formally as part of HTML5's `keygen` element.\n\n`<keygen>` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects\nshould not use this element anymore.\n\nThe `node:crypto` module provides the `Certificate` class for working with SPKAC\ndata. The most common usage is handling output generated by the HTML5\n`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally.","summary":"SPKAC is a Certificate Signing Request mechanism originally implemented by Netscape and was specified formally as part of HTML5's `keygen` element.","examples":[],"children":[{"kind":"staticMethod","id":"static-method-certificateexportchallengespkac-encoding","name":"exportChallenge","title":"Static method: `Certificate.exportChallenge(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v9.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The spkac argument can be an ArrayBuffer. Limited the size of the spkac argument to a maximum of 2**31 - 1 bytes."}],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The challenge component of the `spkac` data structure, which\nincludes a public key and a challenge."}},"description":"```mjs\nconst { Certificate } = await import('node:crypto');\nconst spkac = getSpkacSomehow();\nconst challenge = Certificate.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string\n```\n\n```cjs\nconst { Certificate } = require('node:crypto');\nconst spkac = getSpkacSomehow();\nconst challenge = Certificate.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const { Certificate } = await import('node:crypto');\nconst spkac = getSpkacSomehow();\nconst challenge = Certificate.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string"},{"language":"cjs","displayName":null,"code":"const { Certificate } = require('node:crypto');\nconst spkac = getSpkacSomehow();\nconst challenge = Certificate.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string"}],"children":[]},{"kind":"staticMethod","id":"static-method-certificateexportpublickeyspkac-encoding","name":"exportPublicKey","title":"Static method: `Certificate.exportPublicKey(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v9.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The spkac argument can be an ArrayBuffer. Limited the size of the spkac argument to a maximum of 2**31 - 1 bytes."}],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The public key component of the `spkac` data structure,\nwhich includes a public key and a challenge."}},"description":"```mjs\nconst { Certificate } = await import('node:crypto');\nconst spkac = getSpkacSomehow();\nconst publicKey = Certificate.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>\n```\n\n```cjs\nconst { Certificate } = require('node:crypto');\nconst spkac = getSpkacSomehow();\nconst publicKey = Certificate.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const { Certificate } = await import('node:crypto');\nconst spkac = getSpkacSomehow();\nconst publicKey = Certificate.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>"},{"language":"cjs","displayName":null,"code":"const { Certificate } = require('node:crypto');\nconst spkac = getSpkacSomehow();\nconst publicKey = Certificate.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>"}],"children":[]},{"kind":"staticMethod","id":"static-method-certificateverifyspkacspkac-encoding","name":"verifySpkac","title":"Static method: `Certificate.verifySpkac(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v9.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The spkac argument can be an ArrayBuffer. Added encoding. Limited the size of the spkac argument to a maximum of 2**31 - 1 bytes."}],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the given `spkac` data structure is valid,\n`false` otherwise."}},"description":"```mjs\nimport { Buffer } from 'node:buffer';\nconst { Certificate } = await import('node:crypto');\n\nconst spkac = getSpkacSomehow();\nconsole.log(Certificate.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\nconst { Certificate } = require('node:crypto');\n\nconst spkac = getSpkacSomehow();\nconsole.log(Certificate.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { Certificate } = await import('node:crypto');\n\nconst spkac = getSpkacSomehow();\nconsole.log(Certificate.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\nconst { Certificate } = require('node:crypto');\n\nconst spkac = getSpkacSomehow();\nconsole.log(Certificate.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false"}],"children":[]},{"kind":"section","id":"legacy-api","name":"Legacy API","title":"Legacy API","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"As a legacy interface, it is possible to create new instances of\nthe `crypto.Certificate` class as illustrated in the examples below.","summary":"As a legacy interface, it is possible to create new instances of the `crypto.Certificate` class as illustrated in the examples below.","examples":[],"children":[{"kind":"constructor","id":"new-cryptocertificate","name":"Certificate","title":"`new crypto.Certificate()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Instances of the `Certificate` class can be created using the `new` keyword\nor by calling `crypto.Certificate()` as a function:\n\n```mjs\nconst { Certificate } = await import('node:crypto');\n\nconst cert1 = new Certificate();\nconst cert2 = Certificate();\n```\n\n```cjs\nconst { Certificate } = require('node:crypto');\n\nconst cert1 = new Certificate();\nconst cert2 = Certificate();\n```","summary":"Instances of the `Certificate` class can be created using the `new` keyword or by calling `crypto.Certificate()` as a function:","examples":[{"language":"mjs","displayName":null,"code":"const { Certificate } = await import('node:crypto');\n\nconst cert1 = new Certificate();\nconst cert2 = Certificate();"},{"language":"cjs","displayName":null,"code":"const { Certificate } = require('node:crypto');\n\nconst cert1 = new Certificate();\nconst cert2 = Certificate();"}],"children":[]},{"kind":"method","id":"certificateexportchallengespkac-encoding","name":"exportChallenge","title":"`certificate.exportChallenge(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The challenge component of the `spkac` data structure, which\nincludes a public key and a challenge."}},"description":"```mjs\nconst { Certificate } = await import('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst challenge = cert.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string\n```\n\n```cjs\nconst { Certificate } = require('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst challenge = cert.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const { Certificate } = await import('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst challenge = cert.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string"},{"language":"cjs","displayName":null,"code":"const { Certificate } = require('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst challenge = cert.exportChallenge(spkac);\nconsole.log(challenge.toString('utf8'));\n// Prints: the challenge as a UTF8 string"}],"children":[]},{"kind":"method","id":"certificateexportpublickeyspkac-encoding","name":"exportPublicKey","title":"`certificate.exportPublicKey(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The public key component of the `spkac` data structure,\nwhich includes a public key and a challenge."}},"description":"```mjs\nconst { Certificate } = await import('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst publicKey = cert.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>\n```\n\n```cjs\nconst { Certificate } = require('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst publicKey = cert.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const { Certificate } = await import('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst publicKey = cert.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>"},{"language":"cjs","displayName":null,"code":"const { Certificate } = require('node:crypto');\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconst publicKey = cert.exportPublicKey(spkac);\nconsole.log(publicKey);\n// Prints: the public key as <Buffer ...>"}],"children":[]},{"kind":"method","id":"certificateverifyspkacspkac-encoding","name":"verifySpkac","title":"`certificate.verifySpkac(spkac[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"spkac","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `spkac` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the given `spkac` data structure is valid,\n`false` otherwise."}},"description":"```mjs\nimport { Buffer } from 'node:buffer';\nconst { Certificate } = await import('node:crypto');\n\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconsole.log(cert.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\nconst { Certificate } = require('node:crypto');\n\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconsole.log(cert.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { Certificate } = await import('node:crypto');\n\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconsole.log(cert.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\nconst { Certificate } = require('node:crypto');\n\nconst cert = Certificate();\nconst spkac = getSpkacSomehow();\nconsole.log(cert.verifySpkac(Buffer.from(spkac)));\n// Prints: true or false"}],"children":[]}]}]},{"kind":"class","id":"class-cipheriv","name":"Cipheriv","title":"Class: `Cipheriv`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Transform","links":[{"name":"stream.Transform","href":"stream.html#class-streamtransform","start":0,"end":16}]},"description":"Instances of the `Cipheriv` class are used to encrypt data. The class can be\nused in one of two ways:\n\n* As a [stream](stream.html) that is both readable and writable, where plain unencrypted\n  data is written to produce encrypted data on the readable side, or\n* Using the [`cipher.update()`](#cipherupdatedata-inputencoding-outputencoding) and [`cipher.final()`](#cipherfinaloutputencoding) methods to produce\n  the encrypted data.\n\nThe [`crypto.createCipheriv()`](#cryptocreatecipherivalgorithm-key-iv-options) method is\nused to create `Cipheriv` instances. `Cipheriv` objects are not to be created\ndirectly using the `new` keyword.\n\nExample: Using `Cipheriv` objects as streams:\n\n```mjs\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    // Once we have the key and iv, we can create and use the cipher...\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = '';\n    cipher.setEncoding('hex');\n\n    cipher.on('data', (chunk) => encrypted += chunk);\n    cipher.on('end', () => console.log(encrypted));\n\n    cipher.write('some clear text data');\n    cipher.end();\n  });\n});\n```\n\n```cjs\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    // Once we have the key and iv, we can create and use the cipher...\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = '';\n    cipher.setEncoding('hex');\n\n    cipher.on('data', (chunk) => encrypted += chunk);\n    cipher.on('end', () => console.log(encrypted));\n\n    cipher.write('some clear text data');\n    cipher.end();\n  });\n});\n```\n\nExample: Using `Cipheriv` and piped streams:\n\n```mjs\nimport {\n  createReadStream,\n  createWriteStream,\n} from 'node:fs';\n\nimport {\n  pipeline,\n} from 'node:stream';\n\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    const input = createReadStream('test.js');\n    const output = createWriteStream('test.enc');\n\n    pipeline(input, cipher, output, (err) => {\n      if (err) throw err;\n    });\n  });\n});\n```\n\n```cjs\nconst {\n  createReadStream,\n  createWriteStream,\n} = require('node:fs');\n\nconst {\n  pipeline,\n} = require('node:stream');\n\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    const input = createReadStream('test.js');\n    const output = createWriteStream('test.enc');\n\n    pipeline(input, cipher, output, (err) => {\n      if (err) throw err;\n    });\n  });\n});\n```\n\nExample: Using the [`cipher.update()`](#cipherupdatedata-inputencoding-outputencoding) and [`cipher.final()`](#cipherfinaloutputencoding) methods:\n\n```mjs\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = cipher.update('some clear text data', 'utf8', 'hex');\n    encrypted += cipher.final('hex');\n    console.log(encrypted);\n  });\n});\n```\n\n```cjs\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = cipher.update('some clear text data', 'utf8', 'hex');\n    encrypted += cipher.final('hex');\n    console.log(encrypted);\n  });\n});\n```","summary":"Instances of the `Cipheriv` class are used to encrypt data. The class can be used in one of two ways:","examples":[{"language":"mjs","displayName":null,"code":"const {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    // Once we have the key and iv, we can create and use the cipher...\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = '';\n    cipher.setEncoding('hex');\n\n    cipher.on('data', (chunk) => encrypted += chunk);\n    cipher.on('end', () => console.log(encrypted));\n\n    cipher.write('some clear text data');\n    cipher.end();\n  });\n});"},{"language":"cjs","displayName":null,"code":"const {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    // Once we have the key and iv, we can create and use the cipher...\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = '';\n    cipher.setEncoding('hex');\n\n    cipher.on('data', (chunk) => encrypted += chunk);\n    cipher.on('end', () => console.log(encrypted));\n\n    cipher.write('some clear text data');\n    cipher.end();\n  });\n});"},{"language":"mjs","displayName":null,"code":"import {\n  createReadStream,\n  createWriteStream,\n} from 'node:fs';\n\nimport {\n  pipeline,\n} from 'node:stream';\n\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    const input = createReadStream('test.js');\n    const output = createWriteStream('test.enc');\n\n    pipeline(input, cipher, output, (err) => {\n      if (err) throw err;\n    });\n  });\n});"},{"language":"cjs","displayName":null,"code":"const {\n  createReadStream,\n  createWriteStream,\n} = require('node:fs');\n\nconst {\n  pipeline,\n} = require('node:stream');\n\nconst {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    const input = createReadStream('test.js');\n    const output = createWriteStream('test.enc');\n\n    pipeline(input, cipher, output, (err) => {\n      if (err) throw err;\n    });\n  });\n});"},{"language":"mjs","displayName":null,"code":"const {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = cipher.update('some clear text data', 'utf8', 'hex');\n    encrypted += cipher.final('hex');\n    console.log(encrypted);\n  });\n});"},{"language":"cjs","displayName":null,"code":"const {\n  scrypt,\n  randomFill,\n  createCipheriv,\n} = require('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n\n// First, we'll generate the key. The key length is dependent on the algorithm.\n// In this case for aes192, it is 24 bytes (192 bits).\nscrypt(password, 'salt', 24, (err, key) => {\n  if (err) throw err;\n  // Then, we'll generate a random initialization vector\n  randomFill(new Uint8Array(16), (err, iv) => {\n    if (err) throw err;\n\n    const cipher = createCipheriv(algorithm, key, iv);\n\n    let encrypted = cipher.update('some clear text data', 'utf8', 'hex');\n    encrypted += cipher.final('hex');\n    console.log(encrypted);\n  });\n});"}],"children":[{"kind":"method","id":"cipherfinaloutputencoding","name":"final","title":"`cipher.final([outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"Any remaining enciphered contents.\nIf `outputEncoding` is specified, a string is\nreturned. If an `outputEncoding` is not provided, a [`Buffer`](buffer.html) is returned."}},"description":"If an output encoding was specified in a previous call to\n[`cipher.update()`](#cipherupdatedata-inputencoding-outputencoding), `outputEncoding` must use the same encoding.\n\nOnce the `cipher.final()` method has been called, the `Cipheriv` object can no\nlonger be used to encrypt data. Attempts to call `cipher.final()` more than\nonce will result in an error being thrown.","summary":"If an output encoding was specified in a previous call to `cipher.update()`, `outputEncoding` must use the same encoding.","examples":[],"children":[]},{"kind":"method","id":"ciphergetauthtag","name":"getAuthTag","title":"`cipher.getAuthTag()`","scope":"module","overloadOf":null,"stability":null,"added":["v1.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"When using an authenticated encryption mode (`GCM`, `CCM`,\n`OCB`, `SIV`, `GCM-SIV`, and `chacha20-poly1305` are currently\nsupported), the `cipher.getAuthTag()` method returns a\n[`Buffer`](buffer.html) containing the *authentication tag* that has been computed from\nthe given data."}},"description":"The `cipher.getAuthTag()` method should only be called after encryption has\nbeen completed using the [`cipher.final()`](#cipherfinaloutputencoding) method.\n\nIf the `authTagLength` option was set during the `cipher` instance's creation,\nthis function will return exactly `authTagLength` bytes.","summary":"The `cipher.getAuthTag()` method should only be called after encryption has been completed using the `cipher.final()` method.","examples":[],"children":[]},{"kind":"method","id":"ciphersetaadbuffer-options","name":"setAAD","title":"`cipher.setAAD(buffer[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v1.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[{"name":"plaintextLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `buffer` is a string.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Cipheriv","links":[{"name":"Cipheriv","href":"crypto.html#class-cipheriv","start":0,"end":8}]},"description":"The same `Cipheriv` instance for method chaining."}},"description":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`,\n`GCM-SIV`, and `chacha20-poly1305` are currently supported), the\n`cipher.setAAD()` method sets the value used for the *additional authenticated\ndata* (AAD) input parameter.\n\nThe `plaintextLength` option is optional for `GCM`, `OCB`, `SIV`, and\n`GCM-SIV`. When using `CCM`, the `plaintextLength` option must be specified and\nits value must match the length of the plaintext in bytes. See [CCM mode](#ccm-mode).\n\nThe `cipher.setAAD()` method must be called before [`cipher.update()`](#cipherupdatedata-inputencoding-outputencoding).","summary":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`, `GCM-SIV`, and `chacha20-poly1305` are currently supported), the `cipher.setAAD()` method sets the value used for the _additional authenticated data_ (AAD) input parameter.","examples":[],"children":[]},{"kind":"method","id":"ciphersetautopaddingautopadding","name":"setAutoPadding","title":"`cipher.setAutoPadding([autoPadding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.1"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"autoPadding","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Cipheriv","links":[{"name":"Cipheriv","href":"crypto.html#class-cipheriv","start":0,"end":8}]},"description":"The same `Cipheriv` instance for method chaining."}},"description":"When using block encryption algorithms, the `Cipheriv` class will automatically\nadd padding to the input data to the appropriate block size. To disable the\ndefault padding call `cipher.setAutoPadding(false)`.\n\nWhen `autoPadding` is `false`, the length of the entire input data must be a\nmultiple of the cipher's block size or [`cipher.final()`](#cipherfinaloutputencoding) will throw an error.\nDisabling automatic padding is useful for non-standard padding, for instance\nusing `0x0` instead of PKCS padding.\n\nThe `cipher.setAutoPadding()` method must be called before\n[`cipher.final()`](#cipherfinaloutputencoding).","summary":"When using block encryption algorithms, the `Cipheriv` class will automatically add padding to the input data to the appropriate block size. To disable the default padding call `cipher.setAutoPadding(false)`.","examples":[],"children":[]},{"kind":"method","id":"cipherupdatedata-inputencoding-outputencoding","name":"update","title":"`cipher.update(data[, inputEncoding][, outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the data.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Updates the cipher with `data`. If the `inputEncoding` argument is given,\nthe `data`\nargument is a string using the specified encoding. If the `inputEncoding`\nargument is not given, `data` must be a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or `DataView`, then\n`inputEncoding` is ignored.\n\nThe `outputEncoding` specifies the output format of the enciphered\ndata. If the `outputEncoding`\nis specified, a string using the specified encoding is returned. If no\n`outputEncoding` is provided, a [`Buffer`](buffer.html) is returned.\nWhen `outputEncoding` is specified, it must use the same encoding as previous\ncalls to `cipher.update()`.\n\nThe `cipher.update()` method can be called multiple times with new data until\n[`cipher.final()`](#cipherfinaloutputencoding) is called. Calling `cipher.update()` after\n[`cipher.final()`](#cipherfinaloutputencoding) will result in an error being thrown.","summary":"Updates the cipher with `data`. If the `inputEncoding` argument is given, the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a `Buffer`, `TypedArray`, or `DataView`. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.","examples":[],"children":[]}]},{"kind":"class","id":"class-decipheriv","name":"Decipheriv","title":"Class: `Decipheriv`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Transform","links":[{"name":"stream.Transform","href":"stream.html#class-streamtransform","start":0,"end":16}]},"description":"Instances of the `Decipheriv` class are used to decrypt data. The class can be\nused in one of two ways:\n\n* As a [stream](stream.html) that is both readable and writable, where plain encrypted\n  data is written to produce unencrypted data on the readable side, or\n* Using the [`decipher.update()`](#decipherupdatedata-inputencoding-outputencoding) and [`decipher.final()`](#decipherfinaloutputencoding) methods to\n  produce the unencrypted data.\n\nThe [`crypto.createDecipheriv()`](#cryptocreatedecipherivalgorithm-key-iv-options) method is\nused to create `Decipheriv` instances. `Decipheriv` objects are not to be created\ndirectly using the `new` keyword.\n\nExample: Using `Decipheriv` objects as streams:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Key length is dependent on the algorithm. In this case for aes192, it is\n// 24 bytes (192 bits).\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nlet decrypted = '';\ndecipher.on('readable', () => {\n  let chunk;\n  while (null !== (chunk = decipher.read())) {\n    decrypted += chunk.toString('utf8');\n  }\n});\ndecipher.on('end', () => {\n  console.log(decrypted);\n  // Prints: some clear text data\n});\n\n// Encrypted with same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\ndecipher.write(encrypted, 'hex');\ndecipher.end();\n```\n\n```cjs\nconst {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Key length is dependent on the algorithm. In this case for aes192, it is\n// 24 bytes (192 bits).\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nlet decrypted = '';\ndecipher.on('readable', () => {\n  let chunk;\n  while (null !== (chunk = decipher.read())) {\n    decrypted += chunk.toString('utf8');\n  }\n});\ndecipher.on('end', () => {\n  console.log(decrypted);\n  // Prints: some clear text data\n});\n\n// Encrypted with same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\ndecipher.write(encrypted, 'hex');\ndecipher.end();\n```\n\nExample: Using `Decipheriv` and piped streams:\n\n```mjs\nimport {\n  createReadStream,\n  createWriteStream,\n} from 'node:fs';\nimport { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nconst input = createReadStream('test.enc');\nconst output = createWriteStream('test.js');\n\ninput.pipe(decipher).pipe(output);\n```\n\n```cjs\nconst {\n  createReadStream,\n  createWriteStream,\n} = require('node:fs');\nconst {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nconst input = createReadStream('test.enc');\nconst output = createWriteStream('test.js');\n\ninput.pipe(decipher).pipe(output);\n```\n\nExample: Using the [`decipher.update()`](#decipherupdatedata-inputencoding-outputencoding) and [`decipher.final()`](#decipherfinaloutputencoding) methods:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\n// Encrypted using same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\nlet decrypted = decipher.update(encrypted, 'hex', 'utf8');\ndecrypted += decipher.final('utf8');\nconsole.log(decrypted);\n// Prints: some clear text data\n```\n\n```cjs\nconst {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\n// Encrypted using same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\nlet decrypted = decipher.update(encrypted, 'hex', 'utf8');\ndecrypted += decipher.final('utf8');\nconsole.log(decrypted);\n// Prints: some clear text data\n```","summary":"Instances of the `Decipheriv` class are used to decrypt data. The class can be used in one of two ways:","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Key length is dependent on the algorithm. In this case for aes192, it is\n// 24 bytes (192 bits).\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nlet decrypted = '';\ndecipher.on('readable', () => {\n  let chunk;\n  while (null !== (chunk = decipher.read())) {\n    decrypted += chunk.toString('utf8');\n  }\n});\ndecipher.on('end', () => {\n  console.log(decrypted);\n  // Prints: some clear text data\n});\n\n// Encrypted with same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\ndecipher.write(encrypted, 'hex');\ndecipher.end();"},{"language":"cjs","displayName":null,"code":"const {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Key length is dependent on the algorithm. In this case for aes192, it is\n// 24 bytes (192 bits).\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nlet decrypted = '';\ndecipher.on('readable', () => {\n  let chunk;\n  while (null !== (chunk = decipher.read())) {\n    decrypted += chunk.toString('utf8');\n  }\n});\ndecipher.on('end', () => {\n  console.log(decrypted);\n  // Prints: some clear text data\n});\n\n// Encrypted with same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\ndecipher.write(encrypted, 'hex');\ndecipher.end();"},{"language":"mjs","displayName":null,"code":"import {\n  createReadStream,\n  createWriteStream,\n} from 'node:fs';\nimport { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nconst input = createReadStream('test.enc');\nconst output = createWriteStream('test.js');\n\ninput.pipe(decipher).pipe(output);"},{"language":"cjs","displayName":null,"code":"const {\n  createReadStream,\n  createWriteStream,\n} = require('node:fs');\nconst {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\nconst input = createReadStream('test.enc');\nconst output = createWriteStream('test.js');\n\ninput.pipe(decipher).pipe(output);"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst {\n  scryptSync,\n  createDecipheriv,\n} = await import('node:crypto');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\n// Encrypted using same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\nlet decrypted = decipher.update(encrypted, 'hex', 'utf8');\ndecrypted += decipher.final('utf8');\nconsole.log(decrypted);\n// Prints: some clear text data"},{"language":"cjs","displayName":null,"code":"const {\n  scryptSync,\n  createDecipheriv,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst algorithm = 'aes-192-cbc';\nconst password = 'Password used to generate key';\n// Use the async `crypto.scrypt()` instead.\nconst key = scryptSync(password, 'salt', 24);\n// The IV is usually passed along with the ciphertext.\nconst iv = Buffer.alloc(16, 0); // Initialization vector.\n\nconst decipher = createDecipheriv(algorithm, key, iv);\n\n// Encrypted using same algorithm, key and iv.\nconst encrypted =\n  'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';\nlet decrypted = decipher.update(encrypted, 'hex', 'utf8');\ndecrypted += decipher.final('utf8');\nconsole.log(decrypted);\n// Prints: some clear text data"}],"children":[{"kind":"method","id":"decipherfinaloutputencoding","name":"final","title":"`decipher.final([outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"Any remaining deciphered contents.\nIf `outputEncoding` is specified, a string is\nreturned. If an `outputEncoding` is not provided, a [`Buffer`](buffer.html) is returned."}},"description":"If an output encoding was specified in a previous call to\n[`decipher.update()`](#decipherupdatedata-inputencoding-outputencoding), `outputEncoding` must use the same encoding.\n\nOnce the `decipher.final()` method has been called, the `Decipheriv` object can\nno longer be used to decrypt data. Attempts to call `decipher.final()` more\nthan once will result in an error being thrown.","summary":"If an output encoding was specified in a previous call to `decipher.update()`, `outputEncoding` must use the same encoding.","examples":[],"children":[]},{"kind":"method","id":"deciphersetaadbuffer-options","name":"setAAD","title":"`decipher.setAAD(buffer[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v1.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The buffer argument can be a string or ArrayBuffer and is limited to no more than 2 ** 31 - 1 bytes."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/9398","commit":null,"description":"This method now returns a reference to `decipher`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[{"name":"plaintextLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"String encoding to use when `buffer` is a string.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Decipheriv","links":[{"name":"Decipheriv","href":"crypto.html#class-decipheriv","start":0,"end":10}]},"description":"The same `Decipheriv` instance for method chaining."}},"description":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`,\n`GCM-SIV`, and `chacha20-poly1305` are currently supported), the\n`decipher.setAAD()` method sets the value used for the *additional\nauthenticated data* (AAD) input parameter.\n\nThe `options` argument is optional for `GCM`, `OCB`, `SIV`, and `GCM-SIV`.\nWhen using `CCM`, the `plaintextLength` option must be specified and its value\nmust match the length of the ciphertext in bytes. See [CCM mode](#ccm-mode).\n\nThe `decipher.setAAD()` method must be called before [`decipher.update()`](#decipherupdatedata-inputencoding-outputencoding).\n\nWhen passing a string as the `buffer`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).","summary":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`, `GCM-SIV`, and `chacha20-poly1305` are currently supported), the `decipher.setAAD()` method sets the value used for the _additional authenticated data_ (AAD) input parameter.","examples":[],"children":[]},{"kind":"method","id":"deciphersetauthtagbuffer-encoding","name":"setAuthTag","title":"`decipher.setAuthTag(buffer[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v1.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/61084","commit":null,"description":"Using GCM tag lengths other than 128 bits without specifying the `authTagLength` option when creating `decipher` is not allowed anymore."},{"versions":["v22.0.0","v20.13.0"],"prUrl":"https://github.com/nodejs/node/pull/52345","commit":null,"description":"Using GCM tag lengths other than 128 bits without specifying the `authTagLength` option when creating `decipher` is deprecated."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The buffer argument can be a string or ArrayBuffer and is limited to no more than 2 ** 31 - 1 bytes."},{"versions":["v11.0.0"],"prUrl":"https://github.com/nodejs/node/pull/17825","commit":null,"description":"This method now throws if the GCM tag length is invalid."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/9398","commit":null,"description":"This method now returns a reference to `decipher`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"string | Buffer | ArrayBuffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"String encoding to use when `buffer` is a string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Decipheriv","links":[{"name":"Decipheriv","href":"crypto.html#class-decipheriv","start":0,"end":10}]},"description":"The same `Decipheriv` instance for method chaining."}},"description":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`,\n`GCM-SIV`, and `chacha20-poly1305` are currently supported), the\n`decipher.setAuthTag()` method is used to pass in the received\n*authentication tag*. If no tag is provided, or if the cipher text has been\ntampered with, [`decipher.final()`](#decipherfinaloutputencoding) will throw, indicating that the cipher\ntext should be discarded due to failed authentication. If the tag length is\ninvalid according to [NIST SP 800-38D](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf) or does not match the value of the\n`authTagLength` option, `decipher.setAuthTag()` will throw an error.\n\nThe `decipher.setAuthTag()` method must be called before [`decipher.update()`](#decipherupdatedata-inputencoding-outputencoding)\nfor `CCM`, `SIV`, and `GCM-SIV` modes or before [`decipher.final()`](#decipherfinaloutputencoding) for\n`GCM` and `OCB` modes and `chacha20-poly1305`.\n`decipher.setAuthTag()` can only be called once.\n\nWhen passing a string as the authentication tag, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).","summary":"When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, `SIV`, `GCM-SIV`, and `chacha20-poly1305` are currently supported), the `decipher.setAuthTag()` method is used to pass in the received _authentication tag_. If no tag is provided, or if the cipher text has been tampered with, `decipher.final()` will throw, indicating that the cipher text should be discarded due to failed authentication. If the tag length is invalid according to NIST SP 800-38D or does not match the value of the `authTagLength` option, `decipher.setAuthTag()` will throw an error.","examples":[],"children":[]},{"kind":"method","id":"deciphersetautopaddingautopadding","name":"setAutoPadding","title":"`decipher.setAutoPadding([autoPadding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.1"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"autoPadding","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Decipheriv","links":[{"name":"Decipheriv","href":"crypto.html#class-decipheriv","start":0,"end":10}]},"description":"The same `Decipheriv` instance for method chaining."}},"description":"When data has been encrypted without standard block padding, calling\n`decipher.setAutoPadding(false)` will disable automatic padding to prevent\n[`decipher.final()`](#decipherfinaloutputencoding) from checking for and removing padding.\n\nTurning auto padding off will only work if the input data's length is a\nmultiple of the ciphers block size.\n\nThe `decipher.setAutoPadding()` method must be called before\n[`decipher.final()`](#decipherfinaloutputencoding).","summary":"When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and removing padding.","examples":[],"children":[]},{"kind":"method","id":"decipherupdatedata-inputencoding-outputencoding","name":"update","title":"`decipher.update(data[, inputEncoding][, outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `data` string.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Updates the decipher with `data`. If the `inputEncoding` argument is given,\nthe `data`\nargument is a string using the specified encoding. If the `inputEncoding`\nargument is not given, `data` must be a [`Buffer`](buffer.html). If `data` is a\n[`Buffer`](buffer.html) then `inputEncoding` is ignored.\n\nThe `outputEncoding` specifies the output format of the enciphered\ndata. If the `outputEncoding`\nis specified, a string using the specified encoding is returned. If no\n`outputEncoding` is provided, a [`Buffer`](buffer.html) is returned.\nWhen `outputEncoding` is specified, it must use the same encoding as previous\ncalls to `decipher.update()`.\n\nThe `decipher.update()` method can be called multiple times with new data until\n[`decipher.final()`](#decipherfinaloutputencoding) is called. Calling `decipher.update()` after\n[`decipher.final()`](#decipherfinaloutputencoding) will result in an error being thrown.\n\nEven if the underlying cipher implements authentication, the authenticity and\nintegrity of the plaintext returned from this function may be uncertain at this\ntime. For authenticated encryption algorithms, authenticity is generally only\nestablished when the application calls [`decipher.final()`](#decipherfinaloutputencoding).","summary":"Updates the decipher with `data`. If the `inputEncoding` argument is given, the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is ignored.","examples":[],"children":[]}]},{"kind":"class","id":"class-diffiehellman","name":"DiffieHellman","title":"Class: `DiffieHellman`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"The `DiffieHellman` class is a utility for creating Diffie-Hellman key\nexchanges.\n\nInstances of the `DiffieHellman` class can be created using the\n[`crypto.createDiffieHellman()`](#cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding) function.\n\n```mjs\nimport assert from 'node:assert';\n\nconst {\n  createDiffieHellman,\n} = await import('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createDiffieHellman(2048);\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\n// OK\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n```\n\n```cjs\nconst assert = require('node:assert');\n\nconst {\n  createDiffieHellman,\n} = require('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createDiffieHellman(2048);\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\n// OK\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n```","summary":"The `DiffieHellman` class is a utility for creating Diffie-Hellman key exchanges.","examples":[{"language":"mjs","displayName":null,"code":"import assert from 'node:assert';\n\nconst {\n  createDiffieHellman,\n} = await import('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createDiffieHellman(2048);\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\n// OK\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));"},{"language":"cjs","displayName":null,"code":"const assert = require('node:assert');\n\nconst {\n  createDiffieHellman,\n} = require('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createDiffieHellman(2048);\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\n// OK\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));"}],"children":[{"kind":"method","id":"diffiehellmancomputesecretotherpublickey-inputencoding-outputencoding","name":"computeSecret","title":"`diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"otherPublicKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of an `otherPublicKey` string.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Computes the shared secret using `otherPublicKey` as the other\nparty's public key and returns the computed shared secret. The supplied\nkey is interpreted using the specified `inputEncoding`, and secret is\nencoded using specified `outputEncoding`.\nIf the `inputEncoding` is not\nprovided, `otherPublicKey` is expected to be a [`Buffer`](buffer.html),\n`TypedArray`, or `DataView`.\n\nIf `outputEncoding` is given a string is returned; otherwise, a\n[`Buffer`](buffer.html) is returned.","summary":"Computes the shared secret using `otherPublicKey` as the other party's public key and returns the computed shared secret. The supplied key is interpreted using the specified `inputEncoding`, and secret is encoded using specified `outputEncoding`. If the `inputEncoding` is not provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmangeneratekeysencoding","name":"generateKeys","title":"`diffieHellman.generateKeys([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Generates private and public Diffie-Hellman key values unless they have been\ngenerated or computed already, and returns\nthe public key in the specified `encoding`. This key should be\ntransferred to the other party.\nIf `encoding` is provided a string is returned; otherwise a\n[`Buffer`](buffer.html) is returned.\n\nThis function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,\nonce a private key has been generated or set, calling this function only\nrecomputes the public key from the existing private key. Since the public key is\ndetermined by the private key, the result will be the same unless the private key\nhas been changed via [`diffieHellman.setPrivateKey()`](#diffiehellmansetprivatekeyprivatekey-encoding).","summary":"Generates private and public Diffie-Hellman key values unless they have been generated or computed already, and returns the public key in the specified `encoding`. This key should be transferred to the other party. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmangetgeneratorencoding","name":"getGenerator","title":"`diffieHellman.getGenerator([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Returns the Diffie-Hellman generator in the specified `encoding`.\nIf `encoding` is provided a string is\nreturned; otherwise a [`Buffer`](buffer.html) is returned.","summary":"Returns the Diffie-Hellman generator in the specified `encoding`. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmangetprimeencoding","name":"getPrime","title":"`diffieHellman.getPrime([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Returns the Diffie-Hellman prime in the specified `encoding`.\nIf `encoding` is provided a string is\nreturned; otherwise a [`Buffer`](buffer.html) is returned.","summary":"Returns the Diffie-Hellman prime in the specified `encoding`. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmangetprivatekeyencoding","name":"getPrivateKey","title":"`diffieHellman.getPrivateKey([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Returns the Diffie-Hellman private key in the specified `encoding`.\nIf `encoding` is provided a\nstring is returned; otherwise a [`Buffer`](buffer.html) is returned.","summary":"Returns the Diffie-Hellman private key in the specified `encoding`. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmangetpublickeyencoding","name":"getPublicKey","title":"`diffieHellman.getPublicKey([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Returns the Diffie-Hellman public key in the specified `encoding`.\nIf `encoding` is provided a\nstring is returned; otherwise a [`Buffer`](buffer.html) is returned.","summary":"Returns the Diffie-Hellman public key in the specified `encoding`. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmansetprivatekeyprivatekey-encoding","name":"setPrivateKey","title":"`diffieHellman.setPrivateKey(privateKey[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"privateKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `privateKey` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Sets the Diffie-Hellman private key. If the `encoding` argument is provided,\n`privateKey` is expected\nto be a string. If no `encoding` is provided, `privateKey` is expected\nto be a [`Buffer`](buffer.html), `TypedArray`, or `DataView`.\n\nThis function does not automatically compute the associated public key. Either\n[`diffieHellman.setPublicKey()`](#diffiehellmansetpublickeypublickey-encoding) or [`diffieHellman.generateKeys()`](#diffiehellmangeneratekeysencoding) can be\nused to manually provide the public key or to automatically derive it.","summary":"Sets the Diffie-Hellman private key. If the `encoding` argument is provided, `privateKey` is expected to be a string. If no `encoding` is provided, `privateKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"method","id":"diffiehellmansetpublickeypublickey-encoding","name":"setPublicKey","title":"`diffieHellman.setPublicKey(publicKey[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"publicKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `publicKey` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Sets the Diffie-Hellman public key. If the `encoding` argument is provided,\n`publicKey` is expected\nto be a string. If no `encoding` is provided, `publicKey` is expected\nto be a [`Buffer`](buffer.html), `TypedArray`, or `DataView`.","summary":"Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected to be a string. If no `encoding` is provided, `publicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"property","id":"diffiehellmanverifyerror","name":"verifyError","title":"`diffieHellman.verifyError`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.12"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"A bit field containing any warnings and/or errors resulting from a check\nperformed during initialization of the `DiffieHellman` object.\n\nThe following values are valid for this property (as defined in `node:constants` module):\n\n* `DH_CHECK_P_NOT_SAFE_PRIME`\n* `DH_CHECK_P_NOT_PRIME`\n* `DH_UNABLE_TO_CHECK_GENERATOR`\n* `DH_NOT_SUITABLE_GENERATOR`","summary":"A bit field containing any warnings and/or errors resulting from a check performed during initialization of the `DiffieHellman` object.","examples":[],"children":[]}]},{"kind":"class","id":"class-diffiehellmangroup","name":"DiffieHellmanGroup","title":"Class: `DiffieHellmanGroup`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"The `DiffieHellmanGroup` class takes a well-known modp group as its argument.\nIt works the same as `DiffieHellman`, except that it does not allow changing\nits keys after creation. In other words, it does not implement `setPublicKey()`\nor `setPrivateKey()` methods.\n\n```mjs\nconst { createDiffieHellmanGroup } = await import('node:crypto');\nconst dh = createDiffieHellmanGroup('modp16');\n```\n\n```cjs\nconst { createDiffieHellmanGroup } = require('node:crypto');\nconst dh = createDiffieHellmanGroup('modp16');\n```\n\nThe following groups are supported:\n\n* `'modp14'` (2048 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 3)\n* `'modp15'` (3072 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 4)\n* `'modp16'` (4096 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 5)\n* `'modp17'` (6144 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 6)\n* `'modp18'` (8192 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 7)\n\nThe following groups are still supported but deprecated (see [Caveats](#support-for-weak-or-compromised-algorithms)):\n\n* `'modp1'` (768 bits, [RFC 2409](https://www.rfc-editor.org/rfc/rfc2409.txt) Section 6.1) <span class=\"deprecated-inline\"></span>\n* `'modp2'` (1024 bits, [RFC 2409](https://www.rfc-editor.org/rfc/rfc2409.txt) Section 6.2) <span class=\"deprecated-inline\"></span>\n* `'modp5'` (1536 bits, [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt) Section 2) <span class=\"deprecated-inline\"></span>\n\nThese deprecated groups might be removed in future versions of Node.js.","summary":"The `DiffieHellmanGroup` class takes a well-known modp group as its argument. It works the same as `DiffieHellman`, except that it does not allow changing its keys after creation. In other words, it does not implement `setPublicKey()` or `setPrivateKey()` methods.","examples":[{"language":"mjs","displayName":null,"code":"const { createDiffieHellmanGroup } = await import('node:crypto');\nconst dh = createDiffieHellmanGroup('modp16');"},{"language":"cjs","displayName":null,"code":"const { createDiffieHellmanGroup } = require('node:crypto');\nconst dh = createDiffieHellmanGroup('modp16');"}],"children":[]},{"kind":"class","id":"class-ecdh","name":"ECDH","title":"Class: `ECDH`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)\nkey exchanges.\n\nInstances of the `ECDH` class can be created using the\n[`crypto.createECDH()`](#cryptocreateecdhcurvename) function.\n\n```mjs\nimport assert from 'node:assert';\n\nconst {\n  createECDH,\n} = await import('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createECDH('secp521r1');\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createECDH('secp521r1');\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n// OK\n```\n\n```cjs\nconst assert = require('node:assert');\n\nconst {\n  createECDH,\n} = require('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createECDH('secp521r1');\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createECDH('secp521r1');\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n// OK\n```","summary":"The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH) key exchanges.","examples":[{"language":"mjs","displayName":null,"code":"import assert from 'node:assert';\n\nconst {\n  createECDH,\n} = await import('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createECDH('secp521r1');\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createECDH('secp521r1');\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n// OK"},{"language":"cjs","displayName":null,"code":"const assert = require('node:assert');\n\nconst {\n  createECDH,\n} = require('node:crypto');\n\n// Generate Alice's keys...\nconst alice = createECDH('secp521r1');\nconst aliceKey = alice.generateKeys();\n\n// Generate Bob's keys...\nconst bob = createECDH('secp521r1');\nconst bobKey = bob.generateKeys();\n\n// Exchange and generate the secret...\nconst aliceSecret = alice.computeSecret(bobKey);\nconst bobSecret = bob.computeSecret(aliceKey);\n\nassert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));\n// OK"}],"children":[{"kind":"staticMethod","id":"static-method-ecdhconvertkeykey-curve-inputencoding-outputencoding-format","name":"convertKey","title":"Static method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"curve","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `key` string.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'uncompressed'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the\nformat specified by `format`. The `format` argument specifies point encoding\nand can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is\ninterpreted using the specified `inputEncoding`, and the returned key is encoded\nusing the specified `outputEncoding`.\n\nUse [`crypto.getCurves()`](#cryptogetcurves) to obtain a list of available curve names.\nOn recent OpenSSL releases, `openssl ecparam -list_curves` will also display\nthe name and description of each available elliptic curve.\n\nIf `format` is not specified the point will be returned in `'uncompressed'`\nformat.\n\nIf the `inputEncoding` is not provided, `key` is expected to be a [`Buffer`](buffer.html),\n`TypedArray`, or `DataView`.\n\nExample (uncompressing a key):\n\n```mjs\nconst {\n  createECDH,\n  ECDH,\n} = await import('node:crypto');\n\nconst ecdh = createECDH('secp256k1');\necdh.generateKeys();\n\nconst compressedKey = ecdh.getPublicKey('hex', 'compressed');\n\nconst uncompressedKey = ECDH.convertKey(compressedKey,\n                                        'secp256k1',\n                                        'hex',\n                                        'hex',\n                                        'uncompressed');\n\n// The converted key and the uncompressed public key should be the same\nconsole.log(uncompressedKey === ecdh.getPublicKey('hex'));\n```\n\n```cjs\nconst {\n  createECDH,\n  ECDH,\n} = require('node:crypto');\n\nconst ecdh = createECDH('secp256k1');\necdh.generateKeys();\n\nconst compressedKey = ecdh.getPublicKey('hex', 'compressed');\n\nconst uncompressedKey = ECDH.convertKey(compressedKey,\n                                        'secp256k1',\n                                        'hex',\n                                        'hex',\n                                        'uncompressed');\n\n// The converted key and the uncompressed public key should be the same\nconsole.log(uncompressedKey === ecdh.getPublicKey('hex'));\n```","summary":"Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the format specified by `format`. The `format` argument specifies point encoding and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is interpreted using the specified `inputEncoding`, and the returned key is encoded using the specified `outputEncoding`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  createECDH,\n  ECDH,\n} = await import('node:crypto');\n\nconst ecdh = createECDH('secp256k1');\necdh.generateKeys();\n\nconst compressedKey = ecdh.getPublicKey('hex', 'compressed');\n\nconst uncompressedKey = ECDH.convertKey(compressedKey,\n                                        'secp256k1',\n                                        'hex',\n                                        'hex',\n                                        'uncompressed');\n\n// The converted key and the uncompressed public key should be the same\nconsole.log(uncompressedKey === ecdh.getPublicKey('hex'));"},{"language":"cjs","displayName":null,"code":"const {\n  createECDH,\n  ECDH,\n} = require('node:crypto');\n\nconst ecdh = createECDH('secp256k1');\necdh.generateKeys();\n\nconst compressedKey = ecdh.getPublicKey('hex', 'compressed');\n\nconst uncompressedKey = ECDH.convertKey(compressedKey,\n                                        'secp256k1',\n                                        'hex',\n                                        'hex',\n                                        'uncompressed');\n\n// The converted key and the uncompressed public key should be the same\nconsole.log(uncompressedKey === ecdh.getPublicKey('hex'));"}],"children":[]},{"kind":"method","id":"ecdhcomputesecretotherpublickey-inputencoding-outputencoding","name":"computeSecret","title":"`ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/16849","commit":null,"description":"Changed error format to better support invalid public key error."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"otherPublicKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `otherPublicKey` string.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Computes the shared secret using `otherPublicKey` as the other\nparty's public key and returns the computed shared secret. The supplied\nkey is interpreted using specified `inputEncoding`, and the returned secret\nis encoded using the specified `outputEncoding`.\nIf the `inputEncoding` is not\nprovided, `otherPublicKey` is expected to be a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`.\n\nIf `outputEncoding` is given a string will be returned; otherwise a\n[`Buffer`](buffer.html) is returned.\n\n`ecdh.computeSecret` will throw an\n`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`\nlies outside of the elliptic curve. Since `otherPublicKey` is\nusually supplied from a remote user over an insecure network,\nbe sure to handle this exception accordingly.","summary":"Computes the shared secret using `otherPublicKey` as the other party's public key and returns the computed shared secret. The supplied key is interpreted using specified `inputEncoding`, and the returned secret is encoded using the specified `outputEncoding`. If the `inputEncoding` is not provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"method","id":"ecdhgeneratekeysencoding-format","name":"generateKeys","title":"`ecdh.generateKeys([encoding[, format]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'uncompressed'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Generates private and public EC Diffie-Hellman key values, and returns\nthe public key in the specified `format` and `encoding`. This key should be\ntransferred to the other party.\n\nThe `format` argument specifies point encoding and can be `'compressed'` or\n`'uncompressed'`. If `format` is not specified, the point will be returned in\n`'uncompressed'` format.\n\nIf `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html)\nis returned.","summary":"Generates private and public EC Diffie-Hellman key values, and returns the public key in the specified `format` and `encoding`. This key should be transferred to the other party.","examples":[],"children":[]},{"kind":"method","id":"ecdhgetprivatekeyencoding","name":"getPrivateKey","title":"`ecdh.getPrivateKey([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"The EC Diffie-Hellman in the specified `encoding`."}},"description":"If `encoding` is specified, a string is returned; otherwise a [`Buffer`](buffer.html) is\nreturned.","summary":"If `encoding` is specified, a string is returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"ecdhgetpublickeyencoding-format","name":"getPublicKey","title":"`ecdh.getPublicKey([encoding][, format])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'uncompressed'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"The EC Diffie-Hellman public key in the specified\n`encoding` and `format`."}},"description":"The `format` argument specifies point encoding and can be `'compressed'` or\n`'uncompressed'`. If `format` is not specified the point will be returned in\n`'uncompressed'` format.\n\nIf `encoding` is specified, a string is returned; otherwise a [`Buffer`](buffer.html) is\nreturned.","summary":"The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in `'uncompressed'` format.","examples":[],"children":[]},{"kind":"method","id":"ecdhsetprivatekeyprivatekey-encoding","name":"setPrivateKey","title":"`ecdh.setPrivateKey(privateKey[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"privateKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `privateKey` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Sets the EC Diffie-Hellman private key.\nIf `encoding` is provided, `privateKey` is expected\nto be a string; otherwise `privateKey` is expected to be a [`Buffer`](buffer.html),\n`TypedArray`, or `DataView`.\n\nIf `privateKey` is not valid for the curve specified when the `ECDH` object was\ncreated, an error is thrown. Upon setting the private key, the associated\npublic point (key) is also generated and set in the `ECDH` object.","summary":"Sets the EC Diffie-Hellman private key. If `encoding` is provided, `privateKey` is expected to be a string; otherwise `privateKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.","examples":[],"children":[]},{"kind":"method","id":"ecdhsetpublickeypublickey-encoding","name":"setPublicKey","title":"`ecdh.setPublicKey(publicKey[, encoding])`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v0.11.14"],"deprecated":["v5.2.0"],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"publicKey","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `publicKey` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Sets the EC Diffie-Hellman public key.\nIf `encoding` is provided `publicKey` is expected to\nbe a string; otherwise a [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.\n\nThere is not normally a reason to call this method because `ECDH`\nonly requires a private key and the other party's public key to compute the\nshared secret. Typically either [`ecdh.generateKeys()`](#ecdhgeneratekeysencoding-format) or\n[`ecdh.setPrivateKey()`](#ecdhsetprivatekeyprivatekey-encoding) will be called. The [`ecdh.setPrivateKey()`](#ecdhsetprivatekeyprivatekey-encoding) method\nattempts to generate the public point/key associated with the private key being\nset.\n\nExample (obtaining a shared secret):\n\n```mjs\nconst {\n  createECDH,\n  createHash,\n} = await import('node:crypto');\n\nconst alice = createECDH('secp256k1');\nconst bob = createECDH('secp256k1');\n\n// This is a shortcut way of specifying one of Alice's previous private\n// keys. It would be unwise to use such a predictable private key in a real\n// application.\nalice.setPrivateKey(\n  createHash('sha256').update('alice', 'utf8').digest(),\n);\n\n// Bob uses a newly generated cryptographically strong\n// pseudorandom key pair\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n// aliceSecret and bobSecret should be the same shared secret value\nconsole.log(aliceSecret === bobSecret);\n```\n\n```cjs\nconst {\n  createECDH,\n  createHash,\n} = require('node:crypto');\n\nconst alice = createECDH('secp256k1');\nconst bob = createECDH('secp256k1');\n\n// This is a shortcut way of specifying one of Alice's previous private\n// keys. It would be unwise to use such a predictable private key in a real\n// application.\nalice.setPrivateKey(\n  createHash('sha256').update('alice', 'utf8').digest(),\n);\n\n// Bob uses a newly generated cryptographically strong\n// pseudorandom key pair\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n// aliceSecret and bobSecret should be the same shared secret value\nconsole.log(aliceSecret === bobSecret);\n```","summary":"Sets the EC Diffie-Hellman public key. If `encoding` is provided `publicKey` is expected to be a string; otherwise a `Buffer`, `TypedArray`, or `DataView` is expected.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  createECDH,\n  createHash,\n} = await import('node:crypto');\n\nconst alice = createECDH('secp256k1');\nconst bob = createECDH('secp256k1');\n\n// This is a shortcut way of specifying one of Alice's previous private\n// keys. It would be unwise to use such a predictable private key in a real\n// application.\nalice.setPrivateKey(\n  createHash('sha256').update('alice', 'utf8').digest(),\n);\n\n// Bob uses a newly generated cryptographically strong\n// pseudorandom key pair\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n// aliceSecret and bobSecret should be the same shared secret value\nconsole.log(aliceSecret === bobSecret);"},{"language":"cjs","displayName":null,"code":"const {\n  createECDH,\n  createHash,\n} = require('node:crypto');\n\nconst alice = createECDH('secp256k1');\nconst bob = createECDH('secp256k1');\n\n// This is a shortcut way of specifying one of Alice's previous private\n// keys. It would be unwise to use such a predictable private key in a real\n// application.\nalice.setPrivateKey(\n  createHash('sha256').update('alice', 'utf8').digest(),\n);\n\n// Bob uses a newly generated cryptographically strong\n// pseudorandom key pair\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n// aliceSecret and bobSecret should be the same shared secret value\nconsole.log(aliceSecret === bobSecret);"}],"children":[]}]},{"kind":"class","id":"class-hash","name":"Hash","title":"Class: `Hash`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Transform","links":[{"name":"stream.Transform","href":"stream.html#class-streamtransform","start":0,"end":16}]},"description":"The `Hash` class is a utility for creating hash digests of data. It can be\nused in one of two ways:\n\n* As a [stream](stream.html) that is both readable and writable, where data is written\n  to produce a computed hash digest on the readable side, or\n* Using the [`hash.update()`](#hashupdatedata-inputencoding) and [`hash.digest()`](#hashdigestencoding) methods to produce the\n  computed hash.\n\nThe [`crypto.createHash()`](#cryptocreatehashalgorithm-options) method is used to create `Hash` instances. `Hash`\nobjects are not to be created directly using the `new` keyword.\n\nExample: Using `Hash` objects as streams:\n\n```mjs\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hash.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n  }\n});\n\nhash.write('some data to hash');\nhash.end();\n```\n\n```cjs\nconst {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hash.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n  }\n});\n\nhash.write('some data to hash');\nhash.end();\n```\n\nExample: Using `Hash` and piped streams:\n\n```mjs\nimport { createReadStream } from 'node:fs';\nimport { stdout } from 'node:process';\nconst { createHash } = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream('test.js');\ninput.pipe(hash).setEncoding('hex').pipe(stdout);\n```\n\n```cjs\nconst { createReadStream } = require('node:fs');\nconst { createHash } = require('node:crypto');\nconst { stdout } = require('node:process');\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream('test.js');\ninput.pipe(hash).setEncoding('hex').pipe(stdout);\n```\n\nExample: Using the [`hash.update()`](#hashupdatedata-inputencoding) and [`hash.digest()`](#hashdigestencoding) methods:\n\n```mjs\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('some data to hash');\nconsole.log(hash.digest('hex'));\n// Prints:\n//   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n```\n\n```cjs\nconst {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('some data to hash');\nconsole.log(hash.digest('hex'));\n// Prints:\n//   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n```","summary":"The `Hash` class is a utility for creating hash digests of data. It can be used in one of two ways:","examples":[{"language":"mjs","displayName":null,"code":"const {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hash.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n  }\n});\n\nhash.write('some data to hash');\nhash.end();"},{"language":"cjs","displayName":null,"code":"const {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hash.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\n  }\n});\n\nhash.write('some data to hash');\nhash.end();"},{"language":"mjs","displayName":null,"code":"import { createReadStream } from 'node:fs';\nimport { stdout } from 'node:process';\nconst { createHash } = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream('test.js');\ninput.pipe(hash).setEncoding('hex').pipe(stdout);"},{"language":"cjs","displayName":null,"code":"const { createReadStream } = require('node:fs');\nconst { createHash } = require('node:crypto');\nconst { stdout } = require('node:process');\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream('test.js');\ninput.pipe(hash).setEncoding('hex').pipe(stdout);"},{"language":"mjs","displayName":null,"code":"const {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('some data to hash');\nconsole.log(hash.digest('hex'));\n// Prints:\n//   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50"},{"language":"cjs","displayName":null,"code":"const {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('some data to hash');\nconsole.log(hash.digest('hex'));\n// Prints:\n//   6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50"}],"children":[{"kind":"method","id":"hashcopyoptions","name":"copy","title":"`hash.copy([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v13.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Hash","links":[{"name":"Hash","href":"crypto.html#class-hash","start":0,"end":4}]},"description":""}},"description":"Creates a new `Hash` object that contains a deep copy of the internal state\nof the current `Hash` object.\n\nThe optional `options` argument controls stream behavior. For XOF hash\nfunctions such as `'shake256'`, the `outputLength` option can be used to\nspecify the desired output length in bytes.\n\nAn error is thrown when an attempt is made to copy the `Hash` object after\nits [`hash.digest()`](#hashdigestencoding) method has been called.\n\n```mjs\n// Calculate a rolling hash.\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('one');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('two');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('three');\nconsole.log(hash.copy().digest('hex'));\n\n// Etc.\n```\n\n```cjs\n// Calculate a rolling hash.\nconst {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('one');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('two');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('three');\nconsole.log(hash.copy().digest('hex'));\n\n// Etc.\n```","summary":"Creates a new `Hash` object that contains a deep copy of the internal state of the current `Hash` object.","examples":[{"language":"mjs","displayName":null,"code":"// Calculate a rolling hash.\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('one');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('two');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('three');\nconsole.log(hash.copy().digest('hex'));\n\n// Etc."},{"language":"cjs","displayName":null,"code":"// Calculate a rolling hash.\nconst {\n  createHash,\n} = require('node:crypto');\n\nconst hash = createHash('sha256');\n\nhash.update('one');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('two');\nconsole.log(hash.copy().digest('hex'));\n\nhash.update('three');\nconsole.log(hash.copy().digest('hex'));\n\n// Etc."}],"children":[]},{"kind":"method","id":"hashdigestencoding","name":"digest","title":"`hash.digest([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Calculates the digest of all of the data passed to be hashed (using the\n[`hash.update()`](#hashupdatedata-inputencoding) method).\nIf `encoding` is provided a string will be returned; otherwise\na [`Buffer`](buffer.html) is returned.\n\nThe `Hash` object can not be used again after `hash.digest()` method has been\ncalled. Multiple calls will cause an error to be thrown.","summary":"Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method). If `encoding` is provided a string will be returned; otherwise a `Buffer` is returned.","examples":[],"children":[]},{"kind":"method","id":"hashupdatedata-inputencoding","name":"update","title":"`hash.update(data[, inputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `data` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Updates the hash content with the given `data`, the encoding of which\nis given in `inputEncoding`.\nIf `encoding` is not provided, and the `data` is a string, an\nencoding of `'utf8'` is enforced. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`, then `inputEncoding` is ignored.\n\nThis can be called many times with new data as it is streamed.","summary":"Updates the hash content with the given `data`, the encoding of which is given in `inputEncoding`. If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.","examples":[],"children":[]}]},{"kind":"class","id":"class-hmac","name":"Hmac","title":"Class: `Hmac`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Transform","links":[{"name":"stream.Transform","href":"stream.html#class-streamtransform","start":0,"end":16}]},"description":"The `Hmac` class is a utility for creating cryptographic HMAC digests. It can\nbe used in one of two ways:\n\n* As a [stream](stream.html) that is both readable and writable, where data is written\n  to produce a computed HMAC digest on the readable side, or\n* Using the [`hmac.update()`](#hmacupdatedata-inputencoding) and [`hmac.digest()`](#hmacdigestencoding) methods to produce the\n  computed HMAC digest.\n\nThe [`crypto.createHmac()`](#cryptocreatehmacalgorithm-key-options) method is used to create `Hmac` instances. `Hmac`\nobjects are not to be created directly using the `new` keyword.\n\nExample: Using `Hmac` objects as streams:\n\n```mjs\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hmac.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n  }\n});\n\nhmac.write('some data to hash');\nhmac.end();\n```\n\n```cjs\nconst {\n  createHmac,\n} = require('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hmac.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n  }\n});\n\nhmac.write('some data to hash');\nhmac.end();\n```\n\nExample: Using `Hmac` and piped streams:\n\n```mjs\nimport { createReadStream } from 'node:fs';\nimport { stdout } from 'node:process';\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream('test.js');\ninput.pipe(hmac).pipe(stdout);\n```\n\n```cjs\nconst {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHmac,\n} = require('node:crypto');\nconst { stdout } = require('node:process');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream('test.js');\ninput.pipe(hmac).pipe(stdout);\n```\n\nExample: Using the [`hmac.update()`](#hmacupdatedata-inputencoding) and [`hmac.digest()`](#hmacdigestencoding) methods:\n\n```mjs\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.update('some data to hash');\nconsole.log(hmac.digest('hex'));\n// Prints:\n//   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n```\n\n```cjs\nconst {\n  createHmac,\n} = require('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.update('some data to hash');\nconsole.log(hmac.digest('hex'));\n// Prints:\n//   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n```","summary":"The `Hmac` class is a utility for creating cryptographic HMAC digests. It can be used in one of two ways:","examples":[{"language":"mjs","displayName":null,"code":"const {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hmac.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n  }\n});\n\nhmac.write('some data to hash');\nhmac.end();"},{"language":"cjs","displayName":null,"code":"const {\n  createHmac,\n} = require('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = hmac.read();\n  if (data) {\n    console.log(data.toString('hex'));\n    // Prints:\n    //   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e\n  }\n});\n\nhmac.write('some data to hash');\nhmac.end();"},{"language":"mjs","displayName":null,"code":"import { createReadStream } from 'node:fs';\nimport { stdout } from 'node:process';\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream('test.js');\ninput.pipe(hmac).pipe(stdout);"},{"language":"cjs","displayName":null,"code":"const {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHmac,\n} = require('node:crypto');\nconst { stdout } = require('node:process');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream('test.js');\ninput.pipe(hmac).pipe(stdout);"},{"language":"mjs","displayName":null,"code":"const {\n  createHmac,\n} = await import('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.update('some data to hash');\nconsole.log(hmac.digest('hex'));\n// Prints:\n//   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e"},{"language":"cjs","displayName":null,"code":"const {\n  createHmac,\n} = require('node:crypto');\n\nconst hmac = createHmac('sha256', 'a secret');\n\nhmac.update('some data to hash');\nconsole.log(hmac.digest('hex'));\n// Prints:\n//   7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e"}],"children":[{"kind":"method","id":"hmacdigestencoding","name":"digest","title":"`hmac.digest([encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Calculates the HMAC digest of all of the data passed using [`hmac.update()`](#hmacupdatedata-inputencoding).\nIf `encoding` is\nprovided a string is returned; otherwise a [`Buffer`](buffer.html) is returned;\n\nThe `Hmac` object can not be used again after `hmac.digest()` has been\ncalled. Multiple calls to `hmac.digest()` will result in an error being thrown.","summary":"Calculates the HMAC digest of all of the data passed using `hmac.update()`. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned;","examples":[],"children":[]},{"kind":"method","id":"hmacupdatedata-inputencoding","name":"update","title":"`hmac.update(data[, inputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `data` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Updates the `Hmac` content with the given `data`, the encoding of which\nis given in `inputEncoding`.\nIf `encoding` is not provided, and the `data` is a string, an\nencoding of `'utf8'` is enforced. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`, then `inputEncoding` is ignored.\n\nThis can be called many times with new data as it is streamed.","summary":"Updates the `Hmac` content with the given `data`, the encoding of which is given in `inputEncoding`. If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.","examples":[],"children":[]}]},{"kind":"class","id":"class-keyobject","name":"KeyObject","title":"Class: `KeyObject`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA keys."},{"versions":["v14.5.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/33360","commit":null,"description":"Instances of this class can now be passed to worker threads using `postMessage`."},{"versions":["v11.13.0"],"prUrl":"https://github.com/nodejs/node/pull/26438","commit":null,"description":"This class is now exported."}],"extends":null,"description":"Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,\nand each kind of key exposes different functions. The\n[`crypto.createSecretKey()`](#cryptocreatesecretkeykey-encoding), [`crypto.createPublicKey()`](#cryptocreatepublickeykey) and\n[`crypto.createPrivateKey()`](#cryptocreateprivatekeykey) methods are used to create `KeyObject`\ninstances. `KeyObject` objects are not to be created directly using the `new`\nkeyword.\n\nMost applications should consider using the new `KeyObject` API instead of\npassing keys as strings or `Buffer`s due to improved security features.\n\n`KeyObject` instances can be passed to other threads via [`postMessage()`](worker_threads.html#portpostmessagevalue-transferlist).\nThe receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to\nbe listed in the `transferList` argument.","summary":"Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key, and each kind of key exposes different functions. The `crypto.createSecretKey()`, `crypto.createPublicKey()` and `crypto.createPrivateKey()` methods are used to create `KeyObject` instances. `KeyObject` objects are not to be created directly using the `new` keyword.","examples":[],"children":[{"kind":"staticMethod","id":"static-method-keyobjectfromkey","name":"from","title":"Static method: `KeyObject.from(key)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a non-extractable CryptoKey as `key` is deprecated."}],"signature":{"parameters":[{"name":"key","type":{"text":"CryptoKey","links":[{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":0,"end":9}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":""}},"description":"Returns the underlying {KeyObject} of a {CryptoKey}. The returned {KeyObject}\ndoes not retain any of the restrictions imposed by the Web Crypto API on the\noriginal {CryptoKey}, such as the allowed key usages, the algorithm or hash\nalgorithm bindings, and the extractability flag. In particular, the underlying\nkey material of the returned {KeyObject} can always be exported.\n\n```mjs\nconst { KeyObject } = await import('node:crypto');\nconst { subtle } = globalThis.crypto;\n\nconst key = await subtle.generateKey({\n  name: 'HMAC',\n  hash: 'SHA-256',\n  length: 256,\n}, true, ['sign', 'verify']);\n\nconst keyObject = KeyObject.from(key);\nconsole.log(keyObject.symmetricKeySize);\n// Prints: 32 (symmetric key size in bytes)\n```\n\n```cjs\nconst { KeyObject } = require('node:crypto');\nconst { subtle } = globalThis.crypto;\n\n(async function() {\n  const key = await subtle.generateKey({\n    name: 'HMAC',\n    hash: 'SHA-256',\n    length: 256,\n  }, true, ['sign', 'verify']);\n\n  const keyObject = KeyObject.from(key);\n  console.log(keyObject.symmetricKeySize);\n  // Prints: 32 (symmetric key size in bytes)\n})();\n```","summary":"Returns the underlying {KeyObject} of a {CryptoKey}. The returned {KeyObject} does not retain any of the restrictions imposed by the Web Crypto API on the original {CryptoKey}, such as the allowed key usages, the algorithm or hash algorithm bindings, and the extractability flag. In particular, the underlying key material of the returned {KeyObject} can always be exported.","examples":[{"language":"mjs","displayName":null,"code":"const { KeyObject } = await import('node:crypto');\nconst { subtle } = globalThis.crypto;\n\nconst key = await subtle.generateKey({\n  name: 'HMAC',\n  hash: 'SHA-256',\n  length: 256,\n}, true, ['sign', 'verify']);\n\nconst keyObject = KeyObject.from(key);\nconsole.log(keyObject.symmetricKeySize);\n// Prints: 32 (symmetric key size in bytes)"},{"language":"cjs","displayName":null,"code":"const { KeyObject } = require('node:crypto');\nconst { subtle } = globalThis.crypto;\n\n(async function() {\n  const key = await subtle.generateKey({\n    name: 'HMAC',\n    hash: 'SHA-256',\n    length: 256,\n  }, true, ['sign', 'verify']);\n\n  const keyObject = KeyObject.from(key);\n  console.log(keyObject.symmetricKeySize);\n  // Prints: 32 (symmetric key size in bytes)\n})();"}],"children":[]},{"kind":"property","id":"keyobjectasymmetrickeydetails","name":"asymmetricKeyDetails","title":"`keyObject.asymmetricKeyDetails`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v16.9.0"],"prUrl":"https://github.com/nodejs/node/pull/39851","commit":null,"description":"Expose `RSASSA-PSS-params` sequence parameters for RSA-PSS keys."}],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"This property exists only on asymmetric keys. Depending on the type of the key,\nthis object contains information about the key. None of the information obtained\nthrough this property can be used to uniquely identify a key or to compromise\nthe security of the key.\n\nFor RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence,\nthe `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be\nset.\n\nOther key details might be exposed via this API using additional attributes.","summary":"This property exists only on asymmetric keys. Depending on the type of the key, this object contains information about the key. None of the information obtained through this property can be used to uniquely identify a key or to compromise the security of the key.","examples":[],"children":[]},{"kind":"property","id":"keyobjectasymmetrickeytype","name":"asymmetricKeyType","title":"`keyObject.asymmetricKeyType`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59537","commit":null,"description":"Add support for SLH-DSA keys."},{"versions":["v24.7.0"],"prUrl":"https://github.com/nodejs/node/pull/59461","commit":null,"description":"Add support for ML-KEM keys."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA keys."},{"versions":["v13.9.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31178","commit":null,"description":"Added support for `'dh'`."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26960","commit":null,"description":"Added support for `'rsa-pss'`."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26786","commit":null,"description":"This property now returns `undefined` for KeyObject instances of unrecognized type instead of aborting."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26774","commit":null,"description":"Added support for `'x25519'` and `'x448'`."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26319","commit":null,"description":"Added support for `'ed25519'` and `'ed448'`."}],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"For asymmetric keys, this property represents the type of the key. See the\nsupported [asymmetric key types](#asymmetric-key-types).\n\nThis property is `undefined` for unrecognized `KeyObject` types and symmetric\nkeys.","summary":"For asymmetric keys, this property represents the type of the key. See the supported asymmetric key types.","examples":[],"children":[]},{"kind":"method","id":"keyobjectequalsotherkeyobject","name":"equals","title":"`keyObject.equals(otherKeyObject)`","scope":"module","overloadOf":null,"stability":null,"added":["v17.7.0","v16.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"otherKeyObject","type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":"A `KeyObject` with which to\ncompare `keyObject`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` or `false` depending on whether the keys have exactly the same\ntype, value, and parameters. This method is not\n[constant time](https://en.wikipedia.org/wiki/Timing_attack).","summary":"Returns `true` or `false` depending on whether the keys have exactly the same type, value, and parameters. This method is not constant time.","examples":[],"children":[]},{"kind":"method","id":"keyobjectexportoptions","name":"export","title":"`keyObject.export([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62706","commit":null,"description":"Added JWK format support for ML-KEM and SLH-DSA key types."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62240","commit":null,"description":"Added support for `'raw-public'`, `'raw-private'`, and `'raw-seed'` formats."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62178","commit":null,"description":"ML-KEM and ML-DSA private key `'pkcs8'` export now uses seed-only format by default when a seed is available."},{"versions":["v15.9.0"],"prUrl":"https://github.com/nodejs/node/pull/37081","commit":null,"description":"Added support for `'jwk'` format."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"string | Buffer | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":18,"end":24}]},"description":""}},"description":"For symmetric keys, the following encoding options can be used:\n\n* `format` {string} Must be `'buffer'` (default) or `'jwk'`.\n\nFor public keys, the following encoding options can be used:\n\n* `format` {string} Must be `'pem'`, `'der'`, `'jwk'`, or `'raw-public'`.\n  See [asymmetric key types](#asymmetric-key-types) for format support.\n* `type` {string} When `format` is `'pem'` or `'der'`, must be `'pkcs1'`\n  (RSA only) or `'spki'`. For EC keys with `'raw-public'` format, may be\n  `'uncompressed'` (default) or `'compressed'`. Ignored when `format` is\n  `'jwk'`.\n\nFor private keys, the following encoding options can be used:\n\n* `format` {string} Must be `'pem'`, `'der'`, `'jwk'`, `'raw-private'`,\n  or `'raw-seed'`. See [asymmetric key types](#asymmetric-key-types) for format support.\n* `type` {string} When `format` is `'pem'` or `'der'`, must be `'pkcs1'`\n  (RSA only), `'pkcs8'`, or `'sec1'` (EC only). Ignored when `format` is\n  `'jwk'`, `'raw-private'`, or `'raw-seed'`.\n* `cipher` {string} If specified, the private key will be encrypted with\n  the given `cipher` and `passphrase` using PKCS#5 v2.0 password based\n  encryption. Ignored when `format` is `'jwk'`, `'raw-private'`, or\n  `'raw-seed'`.\n* `passphrase` {string | Buffer} The passphrase to use for encryption.\n  Required when `cipher` is specified.\n\nThe result type depends on the selected encoding format, when PEM the\nresult is a string, when DER it will be a buffer containing the data\nencoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. Raw formats return a\n{Buffer} containing the raw key material.\n\nPrivate keys can be encrypted by specifying a `cipher` and `passphrase`.\nThe PKCS#8 `type` supports encryption with both PEM and DER `format` for any\nkey algorithm. PKCS#1 and SEC1 can only be encrypted when the PEM `format` is\nused. For maximum compatibility, use PKCS#8 for encrypted private keys. Since\nPKCS#8 defines its own encryption mechanism, PEM-level encryption is not\nsupported when encrypting a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption\nand [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for PKCS#1 and SEC1 encryption.","summary":"For symmetric keys, the following encoding options can be used:","examples":[],"children":[]},{"kind":"property","id":"keyobjectsymmetrickeysize","name":"symmetricKeySize","title":"`keyObject.symmetricKeySize`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"For secret keys, this property represents the size of the key in bytes. This\nproperty is `undefined` for asymmetric keys.","summary":"For secret keys, this property represents the size of the key in bytes. This property is `undefined` for asymmetric keys.","examples":[],"children":[]},{"kind":"method","id":"keyobjecttocryptokeyalgorithm-extractable-keyusages","name":"toCryptoKey","title":"`keyObject.toCryptoKey(algorithm, extractable, keyUsages)`","scope":"module","overloadOf":null,"stability":null,"added":["v23.0.0","v22.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string | Algorithm | RsaHashedImportParams | EcKeyImportParams | HmacImportParams","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Algorithm","href":"webcrypto.html#class-algorithm","start":9,"end":18},{"name":"RsaHashedImportParams","href":"webcrypto.html#class-rsahashedimportparams","start":21,"end":42},{"name":"EcKeyImportParams","href":"webcrypto.html#class-eckeyimportparams","start":45,"end":62},{"name":"HmacImportParams","href":"webcrypto.html#class-hmacimportparams","start":65,"end":81}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"extractable","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keyUsages","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"* `extractable` {boolean}\n* `keyUsages` {string[]} See [Key usages](webcrypto.html#cryptokeyusages).\n* Returns: {CryptoKey}\n\nConverts a `KeyObject` instance to a `CryptoKey`.","summary":"Converts a `KeyObject` instance to a `CryptoKey`.","examples":[],"children":[]},{"kind":"property","id":"keyobjecttype","name":"type","title":"`keyObject.type`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"Depending on the type of this `KeyObject`, this property is either\n`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys\nor `'private'` for private (asymmetric) keys.","summary":"Depending on the type of this `KeyObject`, this property is either `'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys or `'private'` for private (asymmetric) keys.","examples":[],"children":[]}]},{"kind":"class","id":"class-sign","name":"Sign","title":"Class: `Sign`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Writable","links":[{"name":"stream.Writable","href":"stream.html#class-streamwritable","start":0,"end":15}]},"description":"The `Sign` class is a utility for generating signatures. It can be used in one\nof two ways:\n\n* As a writable [stream](stream.html), where data to be signed is written and the\n  [`sign.sign()`](#signsignprivatekey-outputencoding) method is used to generate and return the signature, or\n* Using the [`sign.update()`](#signupdatedata-inputencoding) and [`sign.sign()`](#signsignprivatekey-outputencoding) methods to produce the\n  signature.\n\nThe [`crypto.createSign()`](#cryptocreatesignalgorithm-options) method is used to create `Sign` instances. The\nargument is the string name of the hash function to use. `Sign` objects are not\nto be created directly using the `new` keyword.\n\nExample: Using `Sign` and [`Verify`](#class-verify) objects as streams:\n\n```mjs\nconst {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = await import('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('ec', {\n  namedCurve: 'sect239k1',\n});\n\nconst sign = createSign('SHA256');\nsign.write('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey, 'hex');\n\nconst verify = createVerify('SHA256');\nverify.write('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature, 'hex'));\n// Prints: true\n```\n\n```cjs\nconst {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = require('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('ec', {\n  namedCurve: 'sect239k1',\n});\n\nconst sign = createSign('SHA256');\nsign.write('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey, 'hex');\n\nconst verify = createVerify('SHA256');\nverify.write('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature, 'hex'));\n// Prints: true\n```\n\nExample: Using the [`sign.update()`](#signupdatedata-inputencoding) and [`verify.update()`](#verifyupdatedata-inputencoding) methods:\n\n```mjs\nconst {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = await import('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('rsa', {\n  modulusLength: 2048,\n});\n\nconst sign = createSign('SHA256');\nsign.update('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey);\n\nconst verify = createVerify('SHA256');\nverify.update('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature));\n// Prints: true\n```\n\n```cjs\nconst {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = require('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('rsa', {\n  modulusLength: 2048,\n});\n\nconst sign = createSign('SHA256');\nsign.update('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey);\n\nconst verify = createVerify('SHA256');\nverify.update('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature));\n// Prints: true\n```","summary":"The `Sign` class is a utility for generating signatures. It can be used in one of two ways:","examples":[{"language":"mjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = await import('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('ec', {\n  namedCurve: 'sect239k1',\n});\n\nconst sign = createSign('SHA256');\nsign.write('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey, 'hex');\n\nconst verify = createVerify('SHA256');\nverify.write('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature, 'hex'));\n// Prints: true"},{"language":"cjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = require('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('ec', {\n  namedCurve: 'sect239k1',\n});\n\nconst sign = createSign('SHA256');\nsign.write('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey, 'hex');\n\nconst verify = createVerify('SHA256');\nverify.write('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature, 'hex'));\n// Prints: true"},{"language":"mjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = await import('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('rsa', {\n  modulusLength: 2048,\n});\n\nconst sign = createSign('SHA256');\nsign.update('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey);\n\nconst verify = createVerify('SHA256');\nverify.update('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature));\n// Prints: true"},{"language":"cjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n  createSign,\n  createVerify,\n} = require('node:crypto');\n\nconst { privateKey, publicKey } = generateKeyPairSync('rsa', {\n  modulusLength: 2048,\n});\n\nconst sign = createSign('SHA256');\nsign.update('some data to sign');\nsign.end();\nconst signature = sign.sign(privateKey);\n\nconst verify = createVerify('SHA256');\nverify.update('some data to sign');\nverify.end();\nconsole.log(verify.verify(publicKey, signature));\n// Prints: true"}],"children":[{"kind":"method","id":"signsignprivatekey-outputencoding","name":"sign","title":"`sign.sign(privateKey[, outputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The privateKey can also be an ArrayBuffer and CryptoKey."},{"versions":["v13.2.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/29292","commit":null,"description":"This function now supports IEEE-P1363 DSA and ECDSA signatures."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26960","commit":null,"description":"This function now supports RSA-PSS keys."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"This function now supports key objects."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11705","commit":null,"description":"Support for RSASSA-PSS and additional options was added."}],"signature":{"parameters":[{"name":"privateKey","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86},{"name":"URL","href":"url.html#the-whatwg-url-api","start":89,"end":92}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"dsaEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"saltLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the return value.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | string","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":""}},"description":"Calculates the signature on all the data passed through using either\n[`sign.update()`](#signupdatedata-inputencoding) or [`sign.write()`](stream.html#writablewritechunk-encoding-callback).\n\nIf `privateKey` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`privateKey` had been passed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey). When\n`privateKey` is a string, `ArrayBuffer`, [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`, it must contain PEM-encoded key material. If it is an object, the\nfollowing additional properties can be passed:\n\n* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the\n  format of the generated signature. It can be one of the following:\n  * `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.\n  * `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.\n* `padding` {integer} Optional padding value for RSA, one of the following:\n\n  * `crypto.constants.RSA_PKCS1_PADDING` (default)\n  * `crypto.constants.RSA_PKCS1_PSS_PADDING`\n\n  `RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function\n  used to sign the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt), unless\n  an MGF1 hash function has been specified as part of the key in compliance with\n  section 3.3 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt).\n* `saltLength` {integer} Salt length for when padding is\n  `RSA_PKCS1_PSS_PADDING`. The special value\n  `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest\n  size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the\n  maximum permissible value.\n\nIf `outputEncoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html)\nis returned.\n\nThe `Sign` object can not be again used after `sign.sign()` method has been\ncalled. Multiple calls to `sign.sign()` will result in an error being thrown.","summary":"Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.","examples":[],"children":[]},{"kind":"method","id":"signupdatedata-inputencoding","name":"update","title":"`sign.update(data[, inputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `data` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Updates the `Sign` content with the given `data`, the encoding of which\nis given in `inputEncoding`.\nIf `encoding` is not provided, and the `data` is a string, an\nencoding of `'utf8'` is enforced. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`, then `inputEncoding` is ignored.\n\nThis can be called many times with new data as it is streamed.","summary":"Updates the `Sign` content with the given `data`, the encoding of which is given in `inputEncoding`. If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.","examples":[],"children":[]}]},{"kind":"class","id":"class-verify","name":"Verify","title":"Class: `Verify`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Writable","links":[{"name":"stream.Writable","href":"stream.html#class-streamwritable","start":0,"end":15}]},"description":"The `Verify` class is a utility for verifying signatures. It can be used in one\nof two ways:\n\n* As a writable [stream](stream.html) where written data is used to validate against the\n  supplied signature, or\n* Using the [`verify.update()`](#verifyupdatedata-inputencoding) and [`verify.verify()`](#verifyverifykey-signature-signatureencoding) methods to verify\n  the signature.\n\nThe [`crypto.createVerify()`](#cryptocreateverifyalgorithm-options) method is used to create `Verify` instances.\n`Verify` objects are not to be created directly using the `new` keyword.\n\nSee [`Sign`](#class-sign) for examples.","summary":"The `Verify` class is a utility for verifying signatures. It can be used in one of two ways:","examples":[],"children":[{"kind":"method","id":"verifyupdatedata-inputencoding","name":"update","title":"`verify.update(data[, inputEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default `inputEncoding` changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"inputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `data` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Updates the `Verify` content with the given `data`, the encoding of which\nis given in `inputEncoding`.\nIf `inputEncoding` is not provided, and the `data` is a string, an\nencoding of `'utf8'` is enforced. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or\n`DataView`, then `inputEncoding` is ignored.\n\nThis can be called many times with new data as it is streamed.","summary":"Updates the `Verify` content with the given `data`, the encoding of which is given in `inputEncoding`. If `inputEncoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.","examples":[],"children":[]},{"kind":"method","id":"verifyverifykey-signature-signatureencoding","name":"verify","title":"`verify.verify(key, signature[, signatureEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The key can also be an ArrayBuffer and CryptoKey."},{"versions":["v13.2.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/29292","commit":null,"description":"This function now supports IEEE-P1363 DSA and ECDSA signatures."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26960","commit":null,"description":"This function now supports RSA-PSS keys."},{"versions":["v11.7.0"],"prUrl":"https://github.com/nodejs/node/pull/25217","commit":null,"description":"The key can now be a private key."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11705","commit":null,"description":"Support for RSASSA-PSS and additional options was added."}],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"dsaEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"saltLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"signature","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signatureEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `signature` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` or `false` depending on the validity of the\nsignature for the data and public key."}},"description":"Verifies the provided data using the given `key` and `signature`.\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`key` had been passed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey). When `key` is a string,\n`ArrayBuffer`, [`Buffer`](buffer.html), `TypedArray`, or `DataView`, it must contain\nPEM-encoded key material. If it is an object, the following additional\nproperties can be passed:\n\n* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the\n  format of the signature. It can be one of the following:\n  * `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.\n  * `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.\n* `padding` {integer} Optional padding value for RSA, one of the following:\n\n  * `crypto.constants.RSA_PKCS1_PADDING` (default)\n  * `crypto.constants.RSA_PKCS1_PSS_PADDING`\n\n  `RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function\n  used to verify the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt), unless\n  an MGF1 hash function has been specified as part of the key in compliance with\n  section 3.3 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt).\n* `saltLength` {integer} Salt length for when padding is\n  `RSA_PKCS1_PSS_PADDING`. The special value\n  `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest\n  size, `crypto.constants.RSA_PSS_SALTLEN_AUTO` (default) causes it to be\n  determined automatically.\n\nThe `signature` argument is the previously calculated signature for the data, in\nthe `signatureEncoding`.\nIf a `signatureEncoding` is specified, the `signature` is expected to be a\nstring; otherwise `signature` is expected to be a [`Buffer`](buffer.html),\n`TypedArray`, or `DataView`.\n\nThe `verify` object can not be used again after `verify.verify()` has been\ncalled. Multiple calls to `verify.verify()` will result in an error being\nthrown.\n\nBecause public keys can be derived from private keys, a private key may\nbe passed instead of a public key.","summary":"Verifies the provided data using the given `key` and `signature`.","examples":[],"children":[]}]},{"kind":"class","id":"class-x509certificate","name":"X509Certificate","title":"Class: `X509Certificate`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"Encapsulates an X509 certificate and provides read-only access to\nits information.\n\n```mjs\nconst { X509Certificate } = await import('node:crypto');\n\nconst x509 = new X509Certificate('{... pem encoded cert ...}');\n\nconsole.log(x509.subject);\n```\n\n```cjs\nconst { X509Certificate } = require('node:crypto');\n\nconst x509 = new X509Certificate('{... pem encoded cert ...}');\n\nconsole.log(x509.subject);\n```","summary":"Encapsulates an X509 certificate and provides read-only access to its information.","examples":[{"language":"mjs","displayName":null,"code":"const { X509Certificate } = await import('node:crypto');\n\nconst x509 = new X509Certificate('{... pem encoded cert ...}');\n\nconsole.log(x509.subject);"},{"language":"cjs","displayName":null,"code":"const { X509Certificate } = require('node:crypto');\n\nconst x509 = new X509Certificate('{... pem encoded cert ...}');\n\nconsole.log(x509.subject);"}],"children":[{"kind":"constructor","id":"new-x509certificatebuffer","name":"X509Certificate","title":"`new X509Certificate(buffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffer","type":{"text":"string | TypedArray | Buffer | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"Buffer","href":"buffer.html#class-buffer","start":22,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"A PEM or DER encoded\nX509 Certificate.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"x509ca","name":"ca","title":"`x509.ca`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Will be `true` if this is a Certificate Authority (CA)\ncertificate.","summary":"","examples":[],"children":[]},{"kind":"method","id":"x509checkemailemail-options","name":"checkEmail","title":"`x509.checkEmail(email[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41600","commit":null,"description":"The subject option now defaults to `'default'`."},{"versions":["v17.5.0","v16.14.1"],"prUrl":"https://github.com/nodejs/node/pull/41599","commit":null,"description":"The `wildcards`, `partialWildcards`, `multiLabelWildcards`, and `singleLabelSubdomains` options have been removed since they had no effect."},{"versions":["v17.5.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41569","commit":null,"description":"The subject option can now be set to `'default'`."}],"signature":{"parameters":[{"name":"email","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"subject","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"`'default'`, `'always'`, or `'never'`.","default":"'default'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":"Returns `email` if the certificate matches,\n`undefined` if it does not."}},"description":"Checks whether the certificate matches the given email address.\n\nIf the `'subject'` option is undefined or set to `'default'`, the certificate\nsubject is only considered if the subject alternative name extension either does\nnot exist or does not contain any email addresses.\n\nIf the `'subject'` option is set to `'always'` and if the subject alternative\nname extension either does not exist or does not contain a matching email\naddress, the certificate subject is considered.\n\nIf the `'subject'` option is set to `'never'`, the certificate subject is never\nconsidered, even if the certificate contains no subject alternative names.","summary":"Checks whether the certificate matches the given email address.","examples":[],"children":[]},{"kind":"method","id":"x509checkhostname-options","name":"checkHost","title":"`x509.checkHost(name[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41600","commit":null,"description":"The subject option now defaults to `'default'`."},{"versions":["v17.5.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41569","commit":null,"description":"The subject option can now be set to `'default'`."}],"signature":{"parameters":[{"name":"name","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"subject","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"`'default'`, `'always'`, or `'never'`.","default":"'default'","optional":true,"rest":false,"properties":[]},{"name":"wildcards","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"partialWildcards","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"multiLabelWildcards","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"singleLabelSubdomains","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":"Returns a subject name that matches `name`,\nor `undefined` if no subject name matches `name`."}},"description":"Checks whether the certificate matches the given host name.\n\nIf the certificate matches the given host name, the matching subject name is\nreturned. The returned name might be an exact match (e.g., `foo.example.com`)\nor it might contain wildcards (e.g., `*.example.com`). Because host name\ncomparisons are case-insensitive, the returned subject name might also differ\nfrom the given `name` in capitalization.\n\nIf the `'subject'` option is undefined or set to `'default'`, the certificate\nsubject is only considered if the subject alternative name extension either does\nnot exist or does not contain any DNS names. This behavior is consistent with\n[RFC 2818](https://www.rfc-editor.org/rfc/rfc2818.txt) (\"HTTP Over TLS\").\n\nIf the `'subject'` option is set to `'always'` and if the subject alternative\nname extension either does not exist or does not contain a matching DNS name,\nthe certificate subject is considered.\n\nIf the `'subject'` option is set to `'never'`, the certificate subject is never\nconsidered, even if the certificate contains no subject alternative names.","summary":"Checks whether the certificate matches the given host name.","examples":[],"children":[]},{"kind":"method","id":"x509checkipip","name":"checkIP","title":"`x509.checkIP(ip)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.5.0","v16.14.1"],"prUrl":"https://github.com/nodejs/node/pull/41571","commit":null,"description":"The `options` argument has been removed since it had no effect."}],"signature":{"parameters":[{"name":"ip","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":"Returns `ip` if the certificate matches,\n`undefined` if it does not."}},"description":"Checks whether the certificate matches the given IP address (IPv4 or IPv6).\n\nOnly [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280.txt) `iPAddress` subject alternative names are considered, and they\nmust match the given `ip` address exactly. Other subject alternative names as\nwell as the subject field of the certificate are ignored.","summary":"Checks whether the certificate matches the given IP address (IPv4 or IPv6).","examples":[],"children":[]},{"kind":"method","id":"x509checkissuedothercert","name":"checkIssued","title":"`x509.checkIssued(otherCert)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"otherCert","type":{"text":"X509Certificate","links":[{"name":"X509Certificate","href":"crypto.html#class-x509certificate","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Checks whether this certificate was potentially issued by the given `otherCert`\nby comparing the certificate metadata.\n\nThis is useful for pruning a list of possible issuer certificates which have been\nselected using a more rudimentary filtering routine, i.e. just based on subject\nand issuer names.\n\nFinally, to verify that this certificate's signature was produced by a private key\ncorresponding to `otherCert`'s public key use [`x509.verify(publicKey)`](#x509verifypublickey)\nwith `otherCert`'s public key represented as a [`KeyObject`](#class-keyobject)\nlike so\n\n```js\nif (!x509.verify(otherCert.publicKey)) {\n  throw new Error('otherCert did not issue x509');\n}\n```","summary":"Checks whether this certificate was potentially issued by the given `otherCert` by comparing the certificate metadata.","examples":[{"language":"js","displayName":null,"code":"if (!x509.verify(otherCert.publicKey)) {\n  throw new Error('otherCert did not issue x509');\n}"}],"children":[]},{"kind":"method","id":"x509checkprivatekeyprivatekey","name":"checkPrivateKey","title":"`x509.checkPrivateKey(privateKey)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"privateKey","type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":"A private key.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Checks whether the public key for this certificate is consistent with\nthe given private key.","summary":"Checks whether the public key for this certificate is consistent with the given private key.","examples":[],"children":[]},{"kind":"property","id":"x509fingerprint","name":"fingerprint","title":"`x509.fingerprint`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The SHA-1 fingerprint of this certificate.\n\nBecause SHA-1 is cryptographically broken and because the security of SHA-1 is\nsignificantly worse than that of algorithms that are commonly used to sign\ncertificates, consider using [`x509.fingerprint256`](#x509fingerprint256) instead.","summary":"The SHA-1 fingerprint of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509fingerprint256","name":"fingerprint256","title":"`x509.fingerprint256`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The SHA-256 fingerprint of this certificate.","summary":"The SHA-256 fingerprint of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509fingerprint512","name":"fingerprint512","title":"`x509.fingerprint512`","scope":"module","overloadOf":null,"stability":null,"added":["v17.2.0","v16.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The SHA-512 fingerprint of this certificate.\n\nBecause computing the SHA-256 fingerprint is usually faster and because it is\nonly half the size of the SHA-512 fingerprint, [`x509.fingerprint256`](#x509fingerprint256) may be\na better choice. While SHA-512 presumably provides a higher level of security in\ngeneral, the security of SHA-256 matches that of most algorithms that are\ncommonly used to sign certificates.","summary":"The SHA-512 fingerprint of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509infoaccess","name":"infoAccess","title":"`x509.infoAccess`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.3.1","v16.13.2"],"prUrl":"https://github.com/nodejs-private/node-private/pull/300","commit":null,"description":"Parts of this string may be encoded as JSON string literals in response to CVE-2021-44532."}],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"A textual representation of the certificate's authority information access\nextension.\n\nThis is a line feed separated list of access descriptions. Each line begins with\nthe access method and the kind of the access location, followed by a colon and\nthe value associated with the access location.\n\nAfter the prefix denoting the access method and the kind of the access location,\nthe remainder of each line might be enclosed in quotes to indicate that the\nvalue is a JSON string literal. For backward compatibility, Node.js only uses\nJSON string literals within this property when necessary to avoid ambiguity.\nThird-party code should be prepared to handle both possible entry formats.","summary":"A textual representation of the certificate's authority information access extension.","examples":[],"children":[]},{"kind":"property","id":"x509issuer","name":"issuer","title":"`x509.issuer`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The issuer identification included in this certificate.","summary":"The issuer identification included in this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509issuercertificate","name":"issuerCertificate","title":"`x509.issuerCertificate`","scope":"module","overloadOf":null,"stability":null,"added":["v15.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"X509Certificate","links":[{"name":"X509Certificate","href":"crypto.html#class-x509certificate","start":0,"end":15}]},"default":null,"description":"The issuer certificate or `undefined` if the issuer certificate is not\navailable.","summary":"The issuer certificate or `undefined` if the issuer certificate is not available.","examples":[],"children":[]},{"kind":"property","id":"x509keyusage","name":"keyUsage","title":"`x509.keyUsage`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"An array detailing the key extended usages for this certificate.","summary":"An array detailing the key extended usages for this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509publickey","name":"publicKey","title":"`x509.publicKey`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"default":null,"description":"The public key {KeyObject} for this certificate.","summary":"The public key {KeyObject} for this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509raw","name":"raw","title":"`x509.raw`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"default":null,"description":"A `Buffer` containing the DER encoding of this certificate.","summary":"A `Buffer` containing the DER encoding of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509serialnumber","name":"serialNumber","title":"`x509.serialNumber`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The serial number of this certificate.\n\nSerial numbers are assigned by certificate authorities and do not uniquely\nidentify certificates. Consider using [`x509.fingerprint256`](#x509fingerprint256) as a unique\nidentifier instead.","summary":"The serial number of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509subject","name":"subject","title":"`x509.subject`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The complete subject of this certificate.","summary":"The complete subject of this certificate.","examples":[],"children":[]},{"kind":"property","id":"x509subjectaltname","name":"subjectAltName","title":"`x509.subjectAltName`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.3.1","v16.13.2"],"prUrl":"https://github.com/nodejs-private/node-private/pull/300","commit":null,"description":"Parts of this string may be encoded as JSON string literals in response to CVE-2021-44532."}],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The subject alternative name specified for this certificate.\n\nThis is a comma-separated list of subject alternative names. Each entry begins\nwith a string identifying the kind of the subject alternative name followed by\na colon and the value associated with the entry.\n\nEarlier versions of Node.js incorrectly assumed that it is safe to split this\nproperty at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However,\nboth malicious and legitimate certificates can contain subject alternative names\nthat include this sequence when represented as a string.\n\nAfter the prefix denoting the type of the entry, the remainder of each entry\nmight be enclosed in quotes to indicate that the value is a JSON string literal.\nFor backward compatibility, Node.js only uses JSON string literals within this\nproperty when necessary to avoid ambiguity. Third-party code should be prepared\nto handle both possible entry formats.","summary":"The subject alternative name specified for this certificate.","examples":[],"children":[]},{"kind":"method","id":"x509tojson","name":"toJSON","title":"`x509.toJSON()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"There is no standard JSON encoding for X509 certificates. The\n`toJSON()` method returns a string containing the PEM encoded\ncertificate.","summary":"There is no standard JSON encoding for X509 certificates. The `toJSON()` method returns a string containing the PEM encoded certificate.","examples":[],"children":[]},{"kind":"method","id":"x509tolegacyobject","name":"toLegacyObject","title":"`x509.toLegacyObject()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Returns information about this certificate using the legacy\n[certificate object](tls.html#certificate-object) encoding.","summary":"Returns information about this certificate using the legacy certificate object encoding.","examples":[],"children":[]},{"kind":"method","id":"x509tostring","name":"toString","title":"`x509.toString()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Returns the PEM-encoded certificate.","summary":"Returns the PEM-encoded certificate.","examples":[],"children":[]},{"kind":"property","id":"x509validfrom","name":"validFrom","title":"`x509.validFrom`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The date/time from which this certificate is valid.","summary":"The date/time from which this certificate is valid.","examples":[],"children":[]},{"kind":"property","id":"x509validfromdate","name":"validFromDate","title":"`x509.validFromDate`","scope":"module","overloadOf":null,"stability":null,"added":["v23.0.0","v22.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The date/time from which this certificate is valid, encapsulated in a `Date` object.","summary":"The date/time from which this certificate is valid, encapsulated in a `Date` object.","examples":[],"children":[]},{"kind":"property","id":"x509validto","name":"validTo","title":"`x509.validTo`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The date/time until which this certificate is valid.","summary":"The date/time until which this certificate is valid.","examples":[],"children":[]},{"kind":"property","id":"x509validtodate","name":"validToDate","title":"`x509.validToDate`","scope":"module","overloadOf":null,"stability":null,"added":["v23.0.0","v22.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The date/time until which this certificate is valid, encapsulated in a `Date` object.","summary":"The date/time until which this certificate is valid, encapsulated in a `Date` object.","examples":[],"children":[]},{"kind":"property","id":"x509signaturealgorithm","name":"signatureAlgorithm","title":"`x509.signatureAlgorithm`","scope":"module","overloadOf":null,"stability":null,"added":["v24.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"default":null,"description":"The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.","summary":"The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.","examples":[],"children":[]},{"kind":"property","id":"x509signaturealgorithmoid","name":"signatureAlgorithmOid","title":"`x509.signatureAlgorithmOid`","scope":"module","overloadOf":null,"stability":null,"added":["v24.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The OID of the algorithm used to sign the certificate.","summary":"The OID of the algorithm used to sign the certificate.","examples":[],"children":[]},{"kind":"method","id":"x509verifypublickey","name":"verify","title":"`x509.verify(publicKey)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"publicKey","type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":"A public key.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Verifies that this certificate was signed by the given public key.\nDoes not perform any other validation checks on the certificate.","summary":"Verifies that this certificate was signed by the given public key. Does not perform any other validation checks on the certificate.","examples":[],"children":[]}]},{"kind":"section","id":"nodecrypto-module-methods-and-properties","name":"node:crypto module methods and properties","title":"`node:crypto` module methods and properties","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"method","id":"cryptoargon2algorithm-parameters-callback","name":"argon2","title":"`crypto.argon2(algorithm, parameters, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v24.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Variant of Argon2, one of `\"argon2d\"`, `\"argon2i\"` or `\"argon2id\"`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"parameters","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"message","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"REQUIRED, this is the password for password\nhashing applications of Argon2.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"nonce","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"REQUIRED, must be at\nleast 8 bytes long. This is the salt for password hashing applications of Argon2.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"parallelism","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, degree of parallelism determines how many computational chains (lanes)\ncan be run. Must be at least `1` and at most `2**24-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"tagLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, the length of the key to generate. Must be at least `4` and\nat most `2**32-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"memory","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, memory cost in 1KiB blocks. Must be at least\n`8 * parallelism` and at most `2**32-1`. The actual number of blocks is rounded\ndown to the nearest multiple of `4 * parallelism`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"passes","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, number of passes (iterations). Must be at least `1` and at most\n`2**32-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"secret","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":56,"end":65}]},"description":"OPTIONAL, Random additional input,\nsimilar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in\npassword hashing applications. If used, must have a length not greater than `2**32-1` bytes.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"associatedData","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":56,"end":65}]},"description":"OPTIONAL, Additional data to\nbe added to the hash, functionally equivalent to salt or secret, but meant for\nnon-random data. If used, must have a length not greater than `2**32-1` bytes.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"derivedKey","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based\nkey derivation function that is designed to be expensive computationally and\nmemory-wise in order to make brute-force attacks unrewarding.\n\nThe `nonce` should be as unique as possible. It is recommended that a nonce is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `message`, `nonce`, `secret` or `associatedData`, please\nconsider [caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nThe `callback` function is called with two arguments: `err` and `derivedKey`.\n`err` is an exception object when key derivation fails, otherwise `err` is\n`null`. `derivedKey` is passed to the callback as a [`Buffer`](buffer.html).\n\nAn exception is thrown when any of the input arguments specify invalid values\nor types.\n\n```mjs\nconst { argon2, randomBytes } = await import('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nargon2('argon2id', parameters, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n});\n```\n\n```cjs\nconst { argon2, randomBytes } = require('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nargon2('argon2id', parameters, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n});\n```","summary":"Provides an asynchronous Argon2 implementation. Argon2 is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.","examples":[{"language":"mjs","displayName":null,"code":"const { argon2, randomBytes } = await import('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nargon2('argon2id', parameters, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n});"},{"language":"cjs","displayName":null,"code":"const { argon2, randomBytes } = require('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nargon2('argon2id', parameters, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n});"}],"children":[]},{"kind":"method","id":"cryptoargon2syncalgorithm-parameters","name":"argon2Sync","title":"`crypto.argon2Sync(algorithm, parameters)`","scope":"module","overloadOf":null,"stability":null,"added":["v24.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Variant of Argon2, one of `\"argon2d\"`, `\"argon2i\"` or `\"argon2id\"`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"parameters","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"message","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"REQUIRED, this is the password for password\nhashing applications of Argon2.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"nonce","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"REQUIRED, must be at\nleast 8 bytes long. This is the salt for password hashing applications of Argon2.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"parallelism","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, degree of parallelism determines how many computational chains (lanes)\ncan be run. Must be at least 1 and at most `2**24-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"tagLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, the length of the key to generate. Must be at least `4` and\nat most `2**32-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"memory","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, memory cost in 1KiB blocks. Must be at least\n`8 * parallelism` and at most `2**32-1`. The actual number of blocks is rounded\ndown to the nearest multiple of `4 * parallelism`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"passes","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"REQUIRED, number of passes (iterations). Must be at least `1` and at most\n`2**32-1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"secret","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":56,"end":65}]},"description":"OPTIONAL, Random additional input,\nsimilar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in\npassword hashing applications. If used, must have a length not greater than `2**32-1` bytes.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"associatedData","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":56,"end":65}]},"description":"OPTIONAL, Additional data to\nbe added to the hash, functionally equivalent to salt or secret, but meant for\nnon-random data. If used, must have a length not greater than `2**32-1` bytes.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Provides a synchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based\nkey derivation function that is designed to be expensive computationally and\nmemory-wise in order to make brute-force attacks unrewarding.\n\nThe `nonce` should be as unique as possible. It is recommended that a nonce is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `message`, `nonce`, `secret` or `associatedData`, please\nconsider [caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nAn exception is thrown when key derivation fails, otherwise the derived key is\nreturned as a [`Buffer`](buffer.html).\n\nAn exception is thrown when any of the input arguments specify invalid values\nor types.\n\n```mjs\nconst { argon2Sync, randomBytes } = await import('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nconst derivedKey = argon2Sync('argon2id', parameters);\nconsole.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n```\n\n```cjs\nconst { argon2Sync, randomBytes } = require('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nconst derivedKey = argon2Sync('argon2id', parameters);\nconsole.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'\n```","summary":"Provides a synchronous Argon2 implementation. Argon2 is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.","examples":[{"language":"mjs","displayName":null,"code":"const { argon2Sync, randomBytes } = await import('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nconst derivedKey = argon2Sync('argon2id', parameters);\nconsole.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'"},{"language":"cjs","displayName":null,"code":"const { argon2Sync, randomBytes } = require('node:crypto');\n\nconst parameters = {\n  message: 'password',\n  nonce: randomBytes(16),\n  parallelism: 4,\n  tagLength: 64,\n  memory: 65536,\n  passes: 3,\n};\n\nconst derivedKey = argon2Sync('argon2id', parameters);\nconsole.log(derivedKey.toString('hex'));  // 'af91dad...9520f15'"}],"children":[]},{"kind":"method","id":"cryptocheckprimecandidate-options-callback","name":"checkPrime","title":"`crypto.checkPrime(candidate[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.8.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"candidate","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"A possible prime encoded as a sequence of big endian octets of arbitrary\nlength.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"checks","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of Miller-Rabin probabilistic primality\niterations to perform. When the value is `0` (zero), a number of checks\nis used that yields a false positive rate of at most 2<sup>-64</sup> for\nrandom input. Care must be used when selecting a number of checks. Refer\nto the OpenSSL documentation for the [`BN_is_prime_ex`](https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html) function `nchecks`\noptions for more details.","default":"0","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"Set to an {Error} object if an error occurred during check.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"result","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the candidate is a prime with an error\nprobability less than `0.25 ** options.checks`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Checks the primality of the `candidate`.","summary":"Checks the primality of the `candidate`.","examples":[],"children":[]},{"kind":"method","id":"cryptocheckprimesynccandidate-options","name":"checkPrimeSync","title":"`crypto.checkPrimeSync(candidate[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.8.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"candidate","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"A possible prime encoded as a sequence of big endian octets of arbitrary\nlength.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"checks","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of Miller-Rabin probabilistic primality\niterations to perform. When the value is `0` (zero), a number of checks\nis used that yields a false positive rate of at most 2<sup>-64</sup> for\nrandom input. Care must be used when selecting a number of checks. Refer\nto the OpenSSL documentation for the [`BN_is_prime_ex`](https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html) function `nchecks`\noptions for more details.","default":"0","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the candidate is a prime with an error\nprobability less than `0.25 ** options.checks`."}},"description":"Checks the primality of the `candidate`.","summary":"Checks the primality of the `candidate`.","examples":[],"children":[]},{"kind":"property","id":"cryptoconstants","name":"constants","title":"`crypto.constants`","scope":"module","overloadOf":null,"stability":null,"added":["v6.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"An object containing commonly used constants for crypto and security related\noperations. The specific constants currently defined are described in\n[Crypto constants](#crypto-constants).","summary":"An object containing commonly used constants for crypto and security related operations. The specific constants currently defined are described in Crypto constants.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatecipherivalgorithm-key-iv-options","name":"createCipheriv","title":"`crypto.createCipheriv(algorithm, key, iv[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63411","commit":null,"description":"Ciphers in SIV and GCM-SIV modes are now supported."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a CryptoKey as `key` is deprecated."},{"versions":["v17.9.0","v16.17.0"],"prUrl":"https://github.com/nodejs/node/pull/42427","commit":null,"description":"The `authTagLength` option is now optional when using the `chacha20-poly1305` cipher and defaults to 16 bytes."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The password and iv arguments can be an ArrayBuffer and are each limited to a maximum of 2 ** 31 - 1 bytes."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"The `key` argument can now be a `KeyObject`."},{"versions":["v11.2.0","v10.17.0"],"prUrl":"https://github.com/nodejs/node/pull/24081","commit":null,"description":"The cipher `chacha20-poly1305` (the IETF variant of ChaCha20-Poly1305) is now supported."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/21447","commit":null,"description":"Ciphers in OCB mode are now supported."},{"versions":["v10.2.0"],"prUrl":"https://github.com/nodejs/node/pull/20235","commit":null,"description":"The `authTagLength` option can now be used to produce shorter authentication tags in GCM mode and defaults to 16 bytes."},{"versions":["v9.9.0"],"prUrl":"https://github.com/nodejs/node/pull/18644","commit":null,"description":"The `iv` parameter may now be `null` for ciphers which do not need an initialization vector."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":68,"end":77}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"iv","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":56,"end":60}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Cipheriv","links":[{"name":"Cipheriv","href":"crypto.html#class-cipheriv","start":0,"end":8}]},"description":""}},"description":"Creates and returns a `Cipheriv` object, with the given `algorithm`, `key` and\ninitialization vector (`iv`).\n\nThe `options` argument controls stream behavior and is optional except when a\ncipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the\n`authTagLength` option is required and specifies the length of the\nauthentication tag in bytes, see [CCM mode](#ccm-mode). In GCM mode, the `authTagLength`\noption is not required but can be used to set the length of the authentication\ntag that will be returned by `getAuthTag()` and defaults to 16 bytes.\nFor `SIV`, `GCM-SIV`, and `chacha20-poly1305`, the `authTagLength` option\ndefaults to 16 bytes. `SIV` and `GCM-SIV` only support 16-byte authentication\ntags.\n\nThe `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On\nrecent OpenSSL releases, `openssl list -cipher-algorithms` will\ndisplay the available cipher algorithms.\n\nThe `key` is the raw key used by the `algorithm` and `iv` is an\n[initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded strings,\n[Buffers](buffer.html), `TypedArray`, or `DataView`s. The `key` may optionally be\na [`KeyObject`](#class-keyobject) of type `secret`. If the cipher does not need\nan initialization vector, `iv` may be `null`.\n\nWhen passing strings for `key` or `iv`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nInitialization vectors should be unpredictable and unique; ideally, they will be\ncryptographically random. They do not have to be secret: IVs are typically just\nadded to ciphertext messages unencrypted. It may sound contradictory that\nsomething has to be unpredictable and unique, but does not have to be secret;\nremember that an attacker must not be able to predict ahead of time what a\ngiven IV will be.","summary":"Creates and returns a `Cipheriv` object, with the given `algorithm`, `key` and initialization vector (`iv`).","examples":[],"children":[]},{"kind":"method","id":"cryptocreatedecipherivalgorithm-key-iv-options","name":"createDecipheriv","title":"`crypto.createDecipheriv(algorithm, key, iv[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63411","commit":null,"description":"Ciphers in SIV and GCM-SIV modes are now supported."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a CryptoKey as `key` is deprecated."},{"versions":["v17.9.0","v16.17.0"],"prUrl":"https://github.com/nodejs/node/pull/42427","commit":null,"description":"The `authTagLength` option is now optional when using the `chacha20-poly1305` cipher and defaults to 16 bytes."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"The `key` argument can now be a `KeyObject`."},{"versions":["v11.2.0","v10.17.0"],"prUrl":"https://github.com/nodejs/node/pull/24081","commit":null,"description":"The cipher `chacha20-poly1305` (the IETF variant of ChaCha20-Poly1305) is now supported."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/21447","commit":null,"description":"Ciphers in OCB mode are now supported."},{"versions":["v10.2.0"],"prUrl":"https://github.com/nodejs/node/pull/20039","commit":null,"description":"The `authTagLength` option can now be used to restrict accepted GCM authentication tag lengths."},{"versions":["v9.9.0"],"prUrl":"https://github.com/nodejs/node/pull/18644","commit":null,"description":"The `iv` parameter may now be `null` for ciphers which do not need an initialization vector."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":68,"end":77}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"iv","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":56,"end":60}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Decipheriv","links":[{"name":"Decipheriv","href":"crypto.html#class-decipheriv","start":0,"end":10}]},"description":""}},"description":"Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key`\nand initialization vector (`iv`).\n\nThe `options` argument controls stream behavior and is optional except when a\ncipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the\n`authTagLength` option is required and specifies the length of the\nauthentication tag in bytes, see [CCM mode](#ccm-mode).\nFor AES-GCM and `chacha20-poly1305`, the `authTagLength` option defaults to 16\nbytes and must be set to a different value if a different length is used. For\n`SIV` and `GCM-SIV`, the `authTagLength` option defaults to 16 bytes and only\n16-byte authentication tags are supported.\n\nThe `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On\nrecent OpenSSL releases, `openssl list -cipher-algorithms` will\ndisplay the available cipher algorithms.\n\nThe `key` is the raw key used by the `algorithm` and `iv` is an\n[initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded strings,\n[Buffers](buffer.html), `TypedArray`, or `DataView`s. The `key` may optionally be\na [`KeyObject`](#class-keyobject) of type `secret`. If the cipher does not need\nan initialization vector, `iv` may be `null`.\n\nWhen passing strings for `key` or `iv`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nInitialization vectors should be unpredictable and unique; ideally, they will be\ncryptographically random. They do not have to be secret: IVs are typically just\nadded to ciphertext messages unencrypted. It may sound contradictory that\nsomething has to be unpredictable and unique, but does not have to be secret;\nremember that an attacker must not be able to predict ahead of time what a given\nIV will be.","summary":"Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).","examples":[],"children":[]},{"kind":"method","id":"cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding","name":"createDiffieHellman","title":"`crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.12"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12223","commit":null,"description":"The `prime` argument can be any `TypedArray` or `DataView` now."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11983","commit":null,"description":"The `prime` argument can be a `Uint8Array` now."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default for the encoding parameters changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"prime","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"primeEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `prime` string.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"generator","type":{"text":"number | string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62}]},"description":"","default":"2","optional":true,"rest":false,"properties":[]},{"name":"generatorEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The [encoding](buffer.html#buffers-and-character-encodings) of the `generator` string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"DiffieHellman","links":[{"name":"DiffieHellman","href":"crypto.html#class-diffiehellman","start":0,"end":13}]},"description":""}},"description":"Creates a `DiffieHellman` key exchange object using the supplied `prime` and an\noptional specific `generator`.\n\nThe `generator` argument can be a number, string, or [`Buffer`](buffer.html). If\n`generator` is not specified, the value `2` is used.\n\nIf `primeEncoding` is specified, `prime` is expected to be a string; otherwise\na [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.\n\nIf `generatorEncoding` is specified, `generator` is expected to be a string;\notherwise a number, [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.","summary":"Creates a `DiffieHellman` key exchange object using the supplied `prime` and an optional specific `generator`.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatediffiehellmanprimelength-generator","name":"createDiffieHellman","title":"`crypto.createDiffieHellman(primeLength[, generator])`","scope":"module","overloadOf":"cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding","stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"primeLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"generator","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":"2","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"DiffieHellman","links":[{"name":"DiffieHellman","href":"crypto.html#class-diffiehellman","start":0,"end":13}]},"description":""}},"description":"Creates a `DiffieHellman` key exchange object and generates a prime of\n`primeLength` bits using an optional specific numeric `generator`.\nIf `generator` is not specified, the value `2` is used.","summary":"Creates a `DiffieHellman` key exchange object and generates a prime of `primeLength` bits using an optional specific numeric `generator`. If `generator` is not specified, the value `2` is used.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatediffiehellmangroupname","name":"createDiffieHellmanGroup","title":"`crypto.createDiffieHellmanGroup(name)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"DiffieHellmanGroup","links":[{"name":"DiffieHellmanGroup","href":"crypto.html#class-diffiehellmangroup","start":0,"end":18}]},"description":""}},"description":"An alias for [`crypto.getDiffieHellman()`](#cryptogetdiffiehellmangroupname)","summary":"An alias for `crypto.getDiffieHellman()`","examples":[],"children":[]},{"kind":"method","id":"cryptocreateecdhcurvename","name":"createECDH","title":"`crypto.createECDH(curveName)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"curveName","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"ECDH","links":[{"name":"ECDH","href":"crypto.html#class-ecdh","start":0,"end":4}]},"description":""}},"description":"Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a\npredefined curve specified by the `curveName` string. Use\n[`crypto.getCurves()`](#cryptogetcurves) to obtain a list of available curve names. On recent\nOpenSSL releases, `openssl ecparam -list_curves` will also display the name\nand description of each available elliptic curve.","summary":"Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a predefined curve specified by the `curveName` string. Use `crypto.getCurves()` to obtain a list of available curve names. On recent OpenSSL releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatehashalgorithm-options","name":"createHash","title":"`crypto.createHash(algorithm[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v12.8.0"],"prUrl":"https://github.com/nodejs/node/pull/28805","commit":null,"description":"The `outputLength` option was added for XOF hash functions."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Hash","links":[{"name":"Hash","href":"crypto.html#class-hash","start":0,"end":4}]},"description":""}},"description":"Creates and returns a `Hash` object that can be used to generate hash digests\nusing the given `algorithm`. Optional `options` argument controls stream\nbehavior. For XOF hash functions such as `'shake256'`, the `outputLength` option\ncan be used to specify the desired output length in bytes.\n\nWhen the data is small (< 5MB) and readily available, [`crypto.hash()`](#cryptohashalgorithm-data-options) is usually faster.\n\nThe `algorithm` is dependent on the available algorithms supported by the\nversion of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.\nOn recent releases of OpenSSL, `openssl list -digest-algorithms` will\ndisplay the available digest algorithms.\n\nExample: generating the sha256 sum of a file\n\n```mjs\nimport {\n  createReadStream,\n} from 'node:fs';\nimport { argv } from 'node:process';\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst filename = argv[2];\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hash.update(data);\n  else {\n    console.log(`${hash.digest('hex')} ${filename}`);\n  }\n});\n```\n\n```cjs\nconst {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHash,\n} = require('node:crypto');\nconst { argv } = require('node:process');\n\nconst filename = argv[2];\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hash.update(data);\n  else {\n    console.log(`${hash.digest('hex')} ${filename}`);\n  }\n});\n```","summary":"Creates and returns a `Hash` object that can be used to generate hash digests using the given `algorithm`. Optional `options` argument controls stream behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option can be used to specify the desired output length in bytes.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  createReadStream,\n} from 'node:fs';\nimport { argv } from 'node:process';\nconst {\n  createHash,\n} = await import('node:crypto');\n\nconst filename = argv[2];\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hash.update(data);\n  else {\n    console.log(`${hash.digest('hex')} ${filename}`);\n  }\n});"},{"language":"cjs","displayName":null,"code":"const {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHash,\n} = require('node:crypto');\nconst { argv } = require('node:process');\n\nconst filename = argv[2];\n\nconst hash = createHash('sha256');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hash.update(data);\n  else {\n    console.log(`${hash.digest('hex')} ${filename}`);\n  }\n});"}],"children":[]},{"kind":"method","id":"cryptocreatehmacalgorithm-key-options","name":"createHmac","title":"`crypto.createHmac(algorithm, key[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.94"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a CryptoKey as `key` is deprecated."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The key can also be an ArrayBuffer or CryptoKey. The encoding option was added. The key cannot contain more than 2 ** 32 - 1 bytes."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"The `key` argument can now be a `KeyObject`."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":68,"end":77}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.transform` options](stream.html#new-streamtransformoptions)","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `key` is a string.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Hmac","links":[{"name":"Hmac","href":"crypto.html#class-hmac","start":0,"end":4}]},"description":""}},"description":"Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.\nOptional `options` argument controls stream behavior.\n\nThe `algorithm` is dependent on the available algorithms supported by the\nversion of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.\nOn recent releases of OpenSSL, `openssl list -digest-algorithms` will\ndisplay the available digest algorithms.\n\nThe `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is\na [`KeyObject`](#class-keyobject), its type must be `secret`. If it is a string, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis). If it was\nobtained from a cryptographically secure source of entropy, such as\n[`crypto.randomBytes()`](#cryptorandombytessize-callback) or [`crypto.generateKey()`](#cryptogeneratekeytype-options-callback), its length should not\nexceed the block size of `algorithm` (e.g., 512 bits for SHA-256).\n\nExample: generating the sha256 HMAC of a file\n\n```mjs\nimport {\n  createReadStream,\n} from 'node:fs';\nimport { argv } from 'node:process';\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst filename = argv[2];\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hmac.update(data);\n  else {\n    console.log(`${hmac.digest('hex')} ${filename}`);\n  }\n});\n```\n\n```cjs\nconst {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHmac,\n} = require('node:crypto');\nconst { argv } = require('node:process');\n\nconst filename = argv[2];\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hmac.update(data);\n  else {\n    console.log(`${hmac.digest('hex')} ${filename}`);\n  }\n});\n```","summary":"Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. Optional `options` argument controls stream behavior.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  createReadStream,\n} from 'node:fs';\nimport { argv } from 'node:process';\nconst {\n  createHmac,\n} = await import('node:crypto');\n\nconst filename = argv[2];\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hmac.update(data);\n  else {\n    console.log(`${hmac.digest('hex')} ${filename}`);\n  }\n});"},{"language":"cjs","displayName":null,"code":"const {\n  createReadStream,\n} = require('node:fs');\nconst {\n  createHmac,\n} = require('node:crypto');\nconst { argv } = require('node:process');\n\nconst filename = argv[2];\n\nconst hmac = createHmac('sha256', 'a secret');\n\nconst input = createReadStream(filename);\ninput.on('readable', () => {\n  // Only one element is going to be produced by the\n  // hash stream.\n  const data = input.read();\n  if (data)\n    hmac.update(data);\n  else {\n    console.log(`${hmac.digest('hex')} ${filename}`);\n  }\n});"}],"children":[]},{"kind":"method","id":"cryptocreateprivatekeykey","name":"createPrivateKey","title":"`crypto.createPrivateKey(key)`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.7.0"],"prUrl":"https://github.com/nodejs/node/pull/63949","commit":null,"description":"The key can also be a URL referencing an object for an OpenSSL STORE loader. The `properties` option was added."},{"versions":["v26.7.0"],"prUrl":"https://github.com/nodejs/node/pull/63188","commit":null,"description":"Passing a CryptoKey as `key` is no longer supported."},{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62706","commit":null,"description":"Added JWK format support for ML-KEM and SLH-DSA key types."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a CryptoKey as `key` is deprecated."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62240","commit":null,"description":"Added support for `'raw-private'` and `'raw-seed'` formats."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA keys."},{"versions":["v15.12.0"],"prUrl":"https://github.com/nodejs/node/pull/37254","commit":null,"description":"The key can also be a JWK object."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The key can also be an ArrayBuffer. The encoding option was added. The key cannot contain more than 2 ** 32 - 1 bytes."}],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"URL","href":"url.html#the-whatwg-url-api","start":65,"end":68}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | Object | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":56,"end":62},{"name":"URL","href":"url.html#the-whatwg-url-api","start":65,"end":68}]},"description":"The key\nmaterial, either in PEM, DER, JWK, or raw format, or a {URL} referencing an\nobject for an OpenSSL STORE loader.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'pem'`, `'der'`, `'jwk'`, `'raw-private'`,\nor `'raw-seed'`.","default":"'pem'","optional":true,"rest":false,"properties":[]},{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'pkcs1'`, `'pkcs8'` or `'sec1'`. This option is\nrequired only if the `format` is `'der'` and ignored otherwise.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"passphrase","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"The passphrase to use for decryption. When\n`key` is a {URL}, this is the optional PIN/passphrase forwarded to the\nSTORE loader.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"properties","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The optional OpenSSL property query used when\nfetching the STORE loader for a {URL} key.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `key` is a string.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"asymmetricKeyType","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Required when `format` is `'raw-private'`\nor `'raw-seed'` and ignored otherwise.\nMust be a [supported key type](#asymmetric-key-types).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"namedCurve","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the curve to use. Required when\n`asymmetricKeyType` is `'ec'` and ignored otherwise.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":""}},"description":"Creates and returns a new key object containing a private key. If `key` is a\nstring or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`\nmust be an object with the properties described above.\n\nIf the private key is encrypted, a `passphrase` must be specified. The length\nof the passphrase is limited to 1024 bytes.","summary":"Creates and returns a new key object containing a private key. If `key` is a string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.","examples":[],"children":[{"kind":"section","id":"private-keys-from-openssl-store-loaders","name":"Private keys from OpenSSL STORE loaders","title":"Private keys from OpenSSL STORE loaders","scope":"module","overloadOf":null,"stability":{"index":"1.1","description":"Active development"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"If `key` is a {URL} (or an object whose `key` is a {URL}), the private key is\nloaded through an OpenSSL STORE loader. The URL is passed to OpenSSL as a URI,\nfor example a `file:` URI or a provider-backed scheme such as `pkcs11:`. When\nthe [Permission Model](permissions.html#permission-model) is enabled, [`--allow-openssl-store`](cli.html#--allow-openssl-store) is required.\n\n> **Warning**: A URI scheme does not pin an OpenSSL STORE loader or prove where\n> the returned key came from. Node.js forwards the URI to OpenSSL, which chooses\n> loaders according to its version and configuration. For example, OpenSSL may\n> offer an opaque URI such as `pkcs11:object=...` (one without `//` after the\n> scheme) to its `file` loader before trying the `pkcs11` loader. If the complete\n> URI is a valid local path and that file exists, it may be loaded instead.\n> Node.js does not verify which loader supplied the key. Do not rely on a\n> provider-specific URI scheme as proof that a key came from that provider or\n> from a hardware device.\n\nConfigured OpenSSL STORE loaders have broad authority and may access files,\ndevices, tokens, or the network. Access performed by a loader is not constrained\nby the `fs.read`, `fs.write`, or `net` permission scopes.\n\nWhen a {URL} is used, `format`, `type`, `asymmetricKeyType`, and `namedCurve`\nare ignored even when those options would otherwise depend on each other, such\nas `type` with `format: 'der'` or `namedCurve` with\n`asymmetricKeyType: 'ec'`. The input is passed to the STORE loader as a URI,\nnot handled as PEM, DER, JWK, or raw key material. `passphrase` is still used as\nthe optional PIN/passphrase passed to the loader, and `encoding` applies if that\n`passphrase` is a string.\n\nUse `passphrase` instead of embedding credentials in the URI passed to the\nSTORE loader. Node.js redacts the URI from its own permission-denial resource\nand diagnostics. Errors reported by OpenSSL or a provider after loading begins\nmay include the URI.\n\nWhen `properties` is specified with a {URL} key, it is passed to OpenSSL as the\nproperty query for selecting the STORE loader. It is not appended to the URL and\nis distinct from provider-specific URI parameters.","summary":"If `key` is a {URL} (or an object whose `key` is a {URL}), the private key is loaded through an OpenSSL STORE loader. The URL is passed to OpenSSL as a URI, for example a `file:` URI or a provider-backed scheme such as `pkcs11:`. When the Permission Model is enabled, `--allow-openssl-store` is required.","examples":[],"children":[]}]},{"kind":"method","id":"cryptocreatepublickeykey","name":"createPublicKey","title":"`crypto.createPublicKey(key)`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62706","commit":null,"description":"Added JWK format support for ML-KEM and SLH-DSA key types."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62453","commit":null,"description":"Passing a CryptoKey as `key` is deprecated."},{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62240","commit":null,"description":"Added support for `'raw-public'` format."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA keys."},{"versions":["v15.12.0"],"prUrl":"https://github.com/nodejs/node/pull/37254","commit":null,"description":"The key can also be a JWK object."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The key can also be an ArrayBuffer. The encoding option was added. The key cannot contain more than 2 ** 32 - 1 bytes."},{"versions":["v11.13.0"],"prUrl":"https://github.com/nodejs/node/pull/26278","commit":null,"description":"The `key` argument can now be a `KeyObject` with type `private`."},{"versions":["v11.7.0"],"prUrl":"https://github.com/nodejs/node/pull/25217","commit":null,"description":"The `key` argument can now be a private key."}],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":56,"end":62}]},"description":"The key\nmaterial, either in PEM, DER, JWK, or raw format.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"format","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'pem'`, `'der'`, `'jwk'`, or `'raw-public'`.","default":"'pem'","optional":true,"rest":false,"properties":[]},{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'pkcs1'` or `'spki'`. This option is\nrequired only if the `format` is `'der'` and ignored otherwise.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `key` is a string.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"asymmetricKeyType","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Required when `format` is `'raw-public'`\nand ignored otherwise.\nMust be a [supported key type](#asymmetric-key-types).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"namedCurve","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the curve to use. Required when\n`asymmetricKeyType` is `'ec'` and ignored otherwise.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":""}},"description":"Creates and returns a new key object containing a public key. If `key` is a\nstring or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`\nwith type `'private'`, the public key is derived from the given private key;\notherwise, `key` must be an object with the properties described above.\n\nIf the format is `'pem'`, the `'key'` may also be an X.509 certificate.\n\nBecause public keys can be derived from private keys, a private key may be\npassed instead of a public key. In that case, this function behaves as if\n[`crypto.createPrivateKey()`](#cryptocreateprivatekeykey) had been called, except that the type of the\nreturned `KeyObject` will be `'public'` and that the private key cannot be\nextracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type\n`'private'` is given, a new `KeyObject` with type `'public'` will be returned\nand it will be impossible to extract the private key from the returned object.\n\nA store-backed private key can be used as a public key by first loading it with\n[`crypto.createPrivateKey()`](#cryptocreateprivatekeykey); a {URL} cannot be passed to\n`crypto.createPublicKey()` directly.","summary":"Creates and returns a new key object containing a public key. If `key` is a string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject` with type `'private'`, the public key is derived from the given private key; otherwise, `key` must be an object with the properties described above.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatesecretkeykey-encoding","name":"createSecretKey","title":"`crypto.createSecretKey(key[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v11.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.8.0","v16.18.0"],"prUrl":"https://github.com/nodejs/node/pull/44201","commit":null,"description":"The key can now be zero-length."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The key can also be an ArrayBuffer or string. The encoding argument was added. The key cannot contain more than 2 ** 32 - 1 bytes."}],"signature":{"parameters":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding when `key` is a string.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":""}},"description":"Creates and returns a new key object containing a secret key for symmetric\nencryption or `Hmac`.","summary":"Creates and returns a new key object containing a secret key for symmetric encryption or `Hmac`.","examples":[],"children":[]},{"kind":"method","id":"cryptocreatesignalgorithm-options","name":"createSign","title":"`crypto.createSign(algorithm[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.Writable` options](stream.html#new-streamwritableoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Sign","links":[{"name":"Sign","href":"crypto.html#class-sign","start":0,"end":4}]},"description":""}},"description":"Creates and returns a `Sign` object that uses the given `algorithm`. Use\n[`crypto.getHashes()`](#cryptogethashes) to obtain the names of the available digest algorithms.\nOptional `options` argument controls the `stream.Writable` behavior.\n\nIn some cases, a `Sign` instance can be created using the name of a signature\nalgorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use\nthe corresponding digest algorithm. This does not work for all signature\nalgorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest\nalgorithm names.","summary":"Creates and returns a `Sign` object that uses the given `algorithm`. Use `crypto.getHashes()` to obtain the names of the available digest algorithms. Optional `options` argument controls the `stream.Writable` behavior.","examples":[],"children":[]},{"kind":"method","id":"cryptocreateverifyalgorithm-options","name":"createVerify","title":"`crypto.createVerify(algorithm[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.92"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"[`stream.Writable` options](stream.html#new-streamwritableoptions)","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Verify","links":[{"name":"Verify","href":"crypto.html#class-verify","start":0,"end":6}]},"description":""}},"description":"Creates and returns a `Verify` object that uses the given algorithm.\nUse [`crypto.getHashes()`](#cryptogethashes) to obtain an array of names of the available\nsigning algorithms. Optional `options` argument controls the\n`stream.Writable` behavior.\n\nIn some cases, a `Verify` instance can be created using the name of a signature\nalgorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use\nthe corresponding digest algorithm. This does not work for all signature\nalgorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest\nalgorithm names.","summary":"Creates and returns a `Verify` object that uses the given algorithm. Use `crypto.getHashes()` to obtain an array of names of the available signing algorithms. Optional `options` argument controls the `stream.Writable` behavior.","examples":[],"children":[]},{"kind":"method","id":"cryptodecapsulatekey-ciphertext-callback","name":"decapsulate","title":"`crypto.decapsulate(key, ciphertext[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v24.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"URL","href":"url.html#the-whatwg-url-api","start":77,"end":80}]},"description":"Private Key","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ciphertext","type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"sharedKey","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"if the `callback` function is not provided."}},"description":"Key decapsulation using a KEM algorithm with a private key.\n\nSupported key types and their KEM algorithms are:\n\n* `'rsa'`[^openssl30] RSA Secret Value Encapsulation\n* `'ec'`[^openssl32] DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)\n* `'x25519'`[^openssl32] DHKEM(X25519, HKDF-SHA256)\n* `'x448'`[^openssl32] DHKEM(X448, HKDF-SHA512)\n* `'ml-kem-512'`[^openssl35] ML-KEM\n* `'ml-kem-768'`[^openssl35] ML-KEM\n* `'ml-kem-1024'`[^openssl35] ML-KEM\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if `key` had been\npassed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey).\n\nIf the `callback` function is provided this function uses libuv's threadpool.","summary":"Key decapsulation using a KEM algorithm with a private key.","examples":[],"children":[]},{"kind":"method","id":"cryptodiffiehellmanoptions-callback","name":"diffieHellman","title":"`crypto.diffieHellman(options[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v13.9.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62527","commit":null,"description":"Accept key data in addition to KeyObject instances."},{"versions":["v23.11.0"],"prUrl":"https://github.com/nodejs/node/pull/57274","commit":null,"description":"Optional callback argument added."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"privateKey","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"URL","href":"url.html#the-whatwg-url-api","start":77,"end":80}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"publicKey","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"secret","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"if the `callback` function is not provided."}},"description":"Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.\nBoth keys must represent the same asymmetric key type and must support either the DH or\nECDH operation.\n\nIf `options.privateKey` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`options.privateKey` had been passed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey).\n\nIf `options.publicKey` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`options.publicKey` had been passed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey).\n\nIf the `callback` function is provided this function uses libuv's threadpool.","summary":"Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`. Both keys must represent the same asymmetric key type and must support either the DH or ECDH operation.","examples":[],"children":[]},{"kind":"method","id":"cryptoencapsulatekey-callback","name":"encapsulate","title":"`crypto.encapsulate(key[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v24.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74}]},"description":"Public Key","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"result","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"sharedKey","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ciphertext","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"if the `callback` function is not provided."}},"description":"Key encapsulation using a KEM algorithm with a public key.\n\nSupported key types and their KEM algorithms are:\n\n* `'rsa'`[^openssl30] RSA Secret Value Encapsulation\n* `'ec'`[^openssl32] DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)\n* `'x25519'`[^openssl32] DHKEM(X25519, HKDF-SHA256)\n* `'x448'`[^openssl32] DHKEM(X448, HKDF-SHA512)\n* `'ml-kem-512'`[^openssl35] ML-KEM\n* `'ml-kem-768'`[^openssl35] ML-KEM\n* `'ml-kem-1024'`[^openssl35] ML-KEM\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if `key` had been\npassed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey).\n\nIf the `callback` function is provided this function uses libuv's threadpool.","summary":"Key encapsulation using a KEM algorithm with a public key.","examples":[],"children":[]},{"kind":"property","id":"cryptofips","name":"fips","title":"`crypto.fips`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v6.0.0"],"deprecated":["v10.0.0"],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"Deprecated property for checking and controlling [FIPS mode](#fips-mode). Use\n[`crypto.getFips()`](#cryptogetfips) and [`crypto.setFips()`](#cryptosetfipsbool) instead.","summary":"Deprecated property for checking and controlling FIPS mode. Use `crypto.getFips()` and `crypto.setFips()` instead.","examples":[],"children":[]},{"kind":"method","id":"cryptogeneratekeytype-options-callback","name":"generateKey","title":"`crypto.generateKey(type, options, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The intended use of the generated secret key. Currently\naccepted values are `'hmac'` and `'aes'`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"length","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The bit length of the key to generate. This must be a\nvalue greater than 0.\n\n* If `type` is `'hmac'`, the minimum is 8, and the maximum length is\n  2<sup>31</sup>-1. If the value is not a multiple of 8, the generated\n  key will be truncated to `Math.floor(length / 8)`.\n* If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously generates a new random secret key of the given `length`. The\n`type` will determine which validations will be performed on the `length`.\n\n```mjs\nconst {\n  generateKey,\n} = await import('node:crypto');\n\ngenerateKey('hmac', { length: 512 }, (err, key) => {\n  if (err) throw err;\n  console.log(key.export().toString('hex'));  // 46e..........620\n});\n```\n\n```cjs\nconst {\n  generateKey,\n} = require('node:crypto');\n\ngenerateKey('hmac', { length: 512 }, (err, key) => {\n  if (err) throw err;\n  console.log(key.export().toString('hex'));  // 46e..........620\n});\n```\n\nThe size of a generated HMAC key should not exceed the block size of the\nunderlying hash function. See [`crypto.createHmac()`](#cryptocreatehmacalgorithm-key-options) for more information.","summary":"Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  generateKey,\n} = await import('node:crypto');\n\ngenerateKey('hmac', { length: 512 }, (err, key) => {\n  if (err) throw err;\n  console.log(key.export().toString('hex'));  // 46e..........620\n});"},{"language":"cjs","displayName":null,"code":"const {\n  generateKey,\n} = require('node:crypto');\n\ngenerateKey('hmac', { length: 512 }, (err, key) => {\n  if (err) throw err;\n  console.log(key.export().toString('hex'));  // 46e..........620\n});"}],"children":[]},{"kind":"method","id":"cryptogeneratekeypairtype-options-callback","name":"generateKeyPair","title":"`crypto.generateKeyPair(type, options, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59537","commit":null,"description":"Add support for SLH-DSA key pairs."},{"versions":["v24.7.0"],"prUrl":"https://github.com/nodejs/node/pull/59461","commit":null,"description":"Add support for ML-KEM key pairs."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA key pairs."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/39927","commit":null,"description":"Add ability to define `RSASSA-PSS-params` sequence parameters for RSA-PSS keys pairs."},{"versions":["v13.9.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31178","commit":null,"description":"Add support for Diffie-Hellman."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26960","commit":null,"description":"Add support for RSA-PSS key pairs."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26774","commit":null,"description":"Add ability to generate X25519 and X448 key pairs."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26554","commit":null,"description":"Add ability to generate Ed25519 and Ed448 key pairs."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"The `generateKeyPair` and `generateKeyPairSync` functions now produce key objects if no encoding was specified."}],"signature":{"parameters":[{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The asymmetric key type to generate. See the\nsupported [asymmetric key types](#asymmetric-key-types).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"modulusLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Key size in bits (RSA, DSA).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"publicExponent","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Public exponent (RSA).","default":"0x10001","optional":true,"rest":false,"properties":[]},{"name":"hashAlgorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the message digest (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mgf1HashAlgorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the message digest used by\nMGF1 (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"saltLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Minimal salt length in bytes (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"divisorLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Size of `q` in bits (DSA).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"namedCurve","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the curve to use (EC).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"prime","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The prime parameter (DH).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"primeLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Prime length in bits (DH).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"generator","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Custom generator (DH).","default":"2","optional":true,"rest":false,"properties":[]},{"name":"groupName","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Diffie-Hellman group name (DH). See\n[`crypto.getDiffieHellman()`](#cryptogetdiffiehellmangroupname).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"paramEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'named'` or `'explicit'` (EC).","default":"'named'","optional":true,"rest":false,"properties":[]},{"name":"publicKeyEncoding","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"See [`keyObject.export()`](#keyobjectexportoptions).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"privateKeyEncoding","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"See [`keyObject.export()`](#keyobjectexportoptions).","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"publicKey","type":{"text":"string | Buffer | KeyObject","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":18,"end":27}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"privateKey","type":{"text":"string | Buffer | KeyObject","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":18,"end":27}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Generates a new asymmetric key pair of the given `type`. See the\nsupported [asymmetric key types](#asymmetric-key-types).\n\nIf a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function\nbehaves as if [`keyObject.export()`](#keyobjectexportoptions) had been called on its result. Otherwise,\nthe respective part of the key is returned as a [`KeyObject`](#class-keyobject).\n\nIt is recommended to encode public keys as `'spki'` and private keys as\n`'pkcs8'` with encryption for long-term storage:\n\n```mjs\nconst {\n  generateKeyPair,\n} = await import('node:crypto');\n\ngenerateKeyPair('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n}, (err, publicKey, privateKey) => {\n  // Handle errors and use the generated key pair.\n});\n```\n\n```cjs\nconst {\n  generateKeyPair,\n} = require('node:crypto');\n\ngenerateKeyPair('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n}, (err, publicKey, privateKey) => {\n  // Handle errors and use the generated key pair.\n});\n```\n\nOn completion, `callback` will be called with `err` set to `undefined` and\n`publicKey` / `privateKey` representing the generated key pair.\n\nIf this method is invoked as its [`util.promisify()`](util.html#utilpromisifyoriginal)ed version, it returns\na `Promise` for an `Object` with `publicKey` and `privateKey` properties.","summary":"Generates a new asymmetric key pair of the given `type`. See the supported asymmetric key types.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  generateKeyPair,\n} = await import('node:crypto');\n\ngenerateKeyPair('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n}, (err, publicKey, privateKey) => {\n  // Handle errors and use the generated key pair.\n});"},{"language":"cjs","displayName":null,"code":"const {\n  generateKeyPair,\n} = require('node:crypto');\n\ngenerateKeyPair('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n}, (err, publicKey, privateKey) => {\n  // Handle errors and use the generated key pair.\n});"}],"children":[]},{"kind":"method","id":"cryptogeneratekeypairsynctype-options","name":"generateKeyPairSync","title":"`crypto.generateKeyPairSync(type, options)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59537","commit":null,"description":"Add support for SLH-DSA key pairs."},{"versions":["v24.7.0"],"prUrl":"https://github.com/nodejs/node/pull/59461","commit":null,"description":"Add support for ML-KEM key pairs."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA key pairs."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/39927","commit":null,"description":"Add ability to define `RSASSA-PSS-params` sequence parameters for RSA-PSS keys pairs."},{"versions":["v13.9.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31178","commit":null,"description":"Add support for Diffie-Hellman."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26960","commit":null,"description":"Add support for RSA-PSS key pairs."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26774","commit":null,"description":"Add ability to generate X25519 and X448 key pairs."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/26554","commit":null,"description":"Add ability to generate Ed25519 and Ed448 key pairs."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"The `generateKeyPair` and `generateKeyPairSync` functions now produce key objects if no encoding was specified."}],"signature":{"parameters":[{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The asymmetric key type to generate. See the\nsupported [asymmetric key types](#asymmetric-key-types).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"modulusLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Key size in bits (RSA, DSA).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"publicExponent","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Public exponent (RSA).","default":"0x10001","optional":true,"rest":false,"properties":[]},{"name":"hashAlgorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the message digest (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mgf1HashAlgorithm","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the message digest used by\nMGF1 (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"saltLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Minimal salt length in bytes (RSA-PSS).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"divisorLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Size of `q` in bits (DSA).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"namedCurve","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Name of the curve to use (EC).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"prime","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"The prime parameter (DH).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"primeLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Prime length in bits (DH).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"generator","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Custom generator (DH).","default":"2","optional":true,"rest":false,"properties":[]},{"name":"groupName","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Diffie-Hellman group name (DH). See\n[`crypto.getDiffieHellman()`](#cryptogetdiffiehellmangroupname).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"paramEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Must be `'named'` or `'explicit'` (EC).","default":"'named'","optional":true,"rest":false,"properties":[]},{"name":"publicKeyEncoding","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"See [`keyObject.export()`](#keyobjectexportoptions).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"privateKeyEncoding","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"See [`keyObject.export()`](#keyobjectexportoptions).","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":""}},"description":"Generates a new asymmetric key pair of the given `type`. See the\nsupported [asymmetric key types](#asymmetric-key-types).\n\nIf a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function\nbehaves as if [`keyObject.export()`](#keyobjectexportoptions) had been called on its result. Otherwise,\nthe respective part of the key is returned as a [`KeyObject`](#class-keyobject).\n\nWhen encoding public keys, it is recommended to use `'spki'`. When encoding\nprivate keys, it is recommended to use `'pkcs8'` with a strong passphrase,\nand to keep the passphrase confidential.\n\n```mjs\nconst {\n  generateKeyPairSync,\n} = await import('node:crypto');\n\nconst {\n  publicKey,\n  privateKey,\n} = generateKeyPairSync('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n});\n```\n\n```cjs\nconst {\n  generateKeyPairSync,\n} = require('node:crypto');\n\nconst {\n  publicKey,\n  privateKey,\n} = generateKeyPairSync('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n});\n```\n\nThe return value `{ publicKey, privateKey }` represents the generated key pair.\nWhen PEM encoding was selected, the respective key will be a string, otherwise\nit will be a buffer containing the data encoded as DER.","summary":"Generates a new asymmetric key pair of the given `type`. See the supported asymmetric key types.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n} = await import('node:crypto');\n\nconst {\n  publicKey,\n  privateKey,\n} = generateKeyPairSync('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n});"},{"language":"cjs","displayName":null,"code":"const {\n  generateKeyPairSync,\n} = require('node:crypto');\n\nconst {\n  publicKey,\n  privateKey,\n} = generateKeyPairSync('rsa', {\n  modulusLength: 4096,\n  publicKeyEncoding: {\n    type: 'spki',\n    format: 'pem',\n  },\n  privateKeyEncoding: {\n    type: 'pkcs8',\n    format: 'pem',\n    cipher: 'aes-256-cbc',\n    passphrase: 'top secret',\n  },\n});"}],"children":[]},{"kind":"method","id":"cryptogeneratekeysynctype-options","name":"generateKeySync","title":"`crypto.generateKeySync(type, options)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The intended use of the generated secret key. Currently\naccepted values are `'hmac'` and `'aes'`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"length","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The bit length of the key to generate.\n\n* If `type` is `'hmac'`, the minimum is 8, and the maximum length is\n  2<sup>31</sup>-1. If the value is not a multiple of 8, the generated\n  key will be truncated to `Math.floor(length / 8)`.\n* If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"KeyObject","links":[{"name":"KeyObject","href":"crypto.html#class-keyobject","start":0,"end":9}]},"description":""}},"description":"Synchronously generates a new random secret key of the given `length`. The\n`type` will determine which validations will be performed on the `length`.\n\n```mjs\nconst {\n  generateKeySync,\n} = await import('node:crypto');\n\nconst key = generateKeySync('hmac', { length: 512 });\nconsole.log(key.export().toString('hex'));  // e89..........41e\n```\n\n```cjs\nconst {\n  generateKeySync,\n} = require('node:crypto');\n\nconst key = generateKeySync('hmac', { length: 512 });\nconsole.log(key.export().toString('hex'));  // e89..........41e\n```\n\nThe size of a generated HMAC key should not exceed the block size of the\nunderlying hash function. See [`crypto.createHmac()`](#cryptocreatehmacalgorithm-key-options) for more information.","summary":"Synchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  generateKeySync,\n} = await import('node:crypto');\n\nconst key = generateKeySync('hmac', { length: 512 });\nconsole.log(key.export().toString('hex'));  // e89..........41e"},{"language":"cjs","displayName":null,"code":"const {\n  generateKeySync,\n} = require('node:crypto');\n\nconst key = generateKeySync('hmac', { length: 512 });\nconsole.log(key.export().toString('hex'));  // e89..........41e"}],"children":[]},{"kind":"method","id":"cryptogenerateprimesize-options-callback","name":"generatePrime","title":"`crypto.generatePrime(size[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.8.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"size","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The size (in bits) of the prime to generate.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"add","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"rem","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"safe","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, the generated prime is returned\nas a `bigint`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"prime","type":{"text":"ArrayBuffer | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":14,"end":20}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Generates a pseudorandom prime of `size` bits.\n\nIf `options.safe` is `true`, the prime will be a safe prime -- that is,\n`(prime - 1) / 2` will also be a prime.\n\nThe `options.add` and `options.rem` parameters can be used to enforce additional\nrequirements, e.g., for Diffie-Hellman:\n\n* If `options.add` and `options.rem` are both set, the prime will satisfy the\n  condition that `prime % add = rem`.\n* If only `options.add` is set and `options.safe` is not `true`, the prime will\n  satisfy the condition that `prime % add = 1`.\n* If only `options.add` is set and `options.safe` is set to `true`, the prime\n  will instead satisfy the condition that `prime % add = 3`. This is necessary\n  because `prime % add = 1` for `options.add > 2` would contradict the condition\n  enforced by `options.safe`.\n* `options.rem` is ignored if `options.add` is not given.\n\nBoth `options.add` and `options.rem` must be encoded as big-endian sequences\nif given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or\n`DataView`.\n\nBy default, the prime is encoded as a big-endian sequence of octets\nin an {ArrayBuffer}. If the `bigint` option is `true`, then a {bigint}\nis provided.\n\nThe `size` of the prime will have a direct impact on how long it takes to\ngenerate the prime. The larger the size, the longer it will take. Because\nwe use OpenSSL's `BN_generate_prime_ex` function, which provides only\nminimal control over our ability to interrupt the generation process,\nit is not recommended to generate overly large primes, as doing so may make\nthe process unresponsive.","summary":"Generates a pseudorandom prime of `size` bits.","examples":[],"children":[]},{"kind":"method","id":"cryptogenerateprimesyncsize-options","name":"generatePrimeSync","title":"`crypto.generatePrimeSync(size[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.8.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"size","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The size (in bits) of the prime to generate.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"add","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"rem","type":{"text":"ArrayBuffer | SharedArrayBuffer | TypedArray | Buffer | DataView | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":34,"end":44},{"name":"Buffer","href":"buffer.html#class-buffer","start":47,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"safe","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, the generated prime is returned\nas a `bigint`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"ArrayBuffer | bigint","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":14,"end":20}]},"description":""}},"description":"Generates a pseudorandom prime of `size` bits.\n\nIf `options.safe` is `true`, the prime will be a safe prime -- that is,\n`(prime - 1) / 2` will also be a prime.\n\nThe `options.add` and `options.rem` parameters can be used to enforce additional\nrequirements, e.g., for Diffie-Hellman:\n\n* If `options.add` and `options.rem` are both set, the prime will satisfy the\n  condition that `prime % add = rem`.\n* If only `options.add` is set and `options.safe` is not `true`, the prime will\n  satisfy the condition that `prime % add = 1`.\n* If only `options.add` is set and `options.safe` is set to `true`, the prime\n  will instead satisfy the condition that `prime % add = 3`. This is necessary\n  because `prime % add = 1` for `options.add > 2` would contradict the condition\n  enforced by `options.safe`.\n* `options.rem` is ignored if `options.add` is not given.\n\nBoth `options.add` and `options.rem` must be encoded as big-endian sequences\nif given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or\n`DataView`.\n\nBy default, the prime is encoded as a big-endian sequence of octets\nin an {ArrayBuffer}. If the `bigint` option is `true`, then a {bigint}\nis provided.\n\nThe `size` of the prime will have a direct impact on how long it takes to\ngenerate the prime. The larger the size, the longer it will take. Because\nwe use OpenSSL's `BN_generate_prime_ex` function, which provides only\nminimal control over our ability to interrupt the generation process,\nit is not recommended to generate overly large primes, as doing so may make\nthe process unresponsive.","summary":"Generates a pseudorandom prime of `size` bits.","examples":[],"children":[]},{"kind":"method","id":"cryptogetcipherinfonameornid-options","name":"getCipherInfo","title":"`crypto.getCipherInfo(nameOrNid[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"nameOrNid","type":{"text":"string | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":15}]},"description":"The name or nid of the cipher to query.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"keyLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"A test key length.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ivLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"A test IV length.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":""}},"description":"Returns information about a given cipher.\n\nSome ciphers accept variable length keys and initialization vectors. By default,\nthe `crypto.getCipherInfo()` method will return the default values for these\nciphers. To test if a given key length or iv length is acceptable for given\ncipher, use the `keyLength` and `ivLength` options. If the given values are\nunacceptable, `undefined` will be returned.","summary":"Returns information about a given cipher.","examples":[],"children":[]},{"kind":"method","id":"cryptogetciphers","name":"getCiphers","title":"`crypto.getCiphers()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"An array with the names of the supported cipher\nalgorithms."}},"description":"```mjs\nconst {\n  getCiphers,\n} = await import('node:crypto');\n\nconsole.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]\n```\n\n```cjs\nconst {\n  getCiphers,\n} = require('node:crypto');\n\nconsole.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const {\n  getCiphers,\n} = await import('node:crypto');\n\nconsole.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]"},{"language":"cjs","displayName":null,"code":"const {\n  getCiphers,\n} = require('node:crypto');\n\nconsole.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]"}],"children":[]},{"kind":"method","id":"cryptogetcurves","name":"getCurves","title":"`crypto.getCurves()`","scope":"module","overloadOf":null,"stability":null,"added":["v2.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"An array with the names of the supported elliptic curves."}},"description":"```mjs\nconst {\n  getCurves,\n} = await import('node:crypto');\n\nconsole.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]\n```\n\n```cjs\nconst {\n  getCurves,\n} = require('node:crypto');\n\nconsole.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const {\n  getCurves,\n} = await import('node:crypto');\n\nconsole.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]"},{"language":"cjs","displayName":null,"code":"const {\n  getCurves,\n} = require('node:crypto');\n\nconsole.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]"}],"children":[]},{"kind":"method","id":"cryptogetdiffiehellmangroupname","name":"getDiffieHellman","title":"`crypto.getDiffieHellman(groupName)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"groupName","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"DiffieHellmanGroup","links":[{"name":"DiffieHellmanGroup","href":"crypto.html#class-diffiehellmangroup","start":0,"end":18}]},"description":""}},"description":"Creates a predefined `DiffieHellmanGroup` key exchange object. The\nsupported groups are listed in the documentation for [`DiffieHellmanGroup`](#class-diffiehellmangroup).\n\nThe returned object mimics the interface of objects created by\n[`crypto.createDiffieHellman()`](#cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding), but will not allow changing\nthe keys (with [`diffieHellman.setPublicKey()`](#diffiehellmansetpublickeypublickey-encoding), for example). The\nadvantage of using this method is that the parties do not have to\ngenerate nor exchange a group modulus beforehand, saving both processor\nand communication time.\n\nExample (obtaining a shared secret):\n\n```mjs\nconst {\n  getDiffieHellman,\n} = await import('node:crypto');\nconst alice = getDiffieHellman('modp14');\nconst bob = getDiffieHellman('modp14');\n\nalice.generateKeys();\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n/* aliceSecret and bobSecret should be the same */\nconsole.log(aliceSecret === bobSecret);\n```\n\n```cjs\nconst {\n  getDiffieHellman,\n} = require('node:crypto');\n\nconst alice = getDiffieHellman('modp14');\nconst bob = getDiffieHellman('modp14');\n\nalice.generateKeys();\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n/* aliceSecret and bobSecret should be the same */\nconsole.log(aliceSecret === bobSecret);\n```","summary":"Creates a predefined `DiffieHellmanGroup` key exchange object. The supported groups are listed in the documentation for `DiffieHellmanGroup`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  getDiffieHellman,\n} = await import('node:crypto');\nconst alice = getDiffieHellman('modp14');\nconst bob = getDiffieHellman('modp14');\n\nalice.generateKeys();\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n/* aliceSecret and bobSecret should be the same */\nconsole.log(aliceSecret === bobSecret);"},{"language":"cjs","displayName":null,"code":"const {\n  getDiffieHellman,\n} = require('node:crypto');\n\nconst alice = getDiffieHellman('modp14');\nconst bob = getDiffieHellman('modp14');\n\nalice.generateKeys();\nbob.generateKeys();\n\nconst aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nconst bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n/* aliceSecret and bobSecret should be the same */\nconsole.log(aliceSecret === bobSecret);"}],"children":[]},{"kind":"method","id":"cryptogetfips","name":"getFips","title":"`crypto.getFips()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"`1` if FIPS mode is enabled, `0` otherwise. A future\nsemver-major release may change the return type of this API to a {boolean}."}},"description":"With OpenSSL 3, this reports whether the default property query includes\n`fips=yes`. It does not establish that a FIPS provider is loaded or validated.\nIt can return `1` even when a requested cryptographic implementation cannot be\nfetched because no loaded provider supplies a match for `fips=yes`. See [FIPS\nmode](#fips-mode).","summary":"With OpenSSL 3, this reports whether the default property query includes `fips=yes`. It does not establish that a FIPS provider is loaded or validated. It can return `1` even when a requested cryptographic implementation cannot be fetched because no loaded provider supplies a match for `fips=yes`. See FIPS mode.","examples":[],"children":[]},{"kind":"method","id":"cryptogethashes","name":"getHashes","title":"`crypto.getHashes()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"An array of the names of the supported hash algorithms,\nsuch as `'RSA-SHA256'`. Hash algorithms are also called \"digest\" algorithms."}},"description":"```mjs\nconst {\n  getHashes,\n} = await import('node:crypto');\n\nconsole.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]\n```\n\n```cjs\nconst {\n  getHashes,\n} = require('node:crypto');\n\nconsole.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]\n```","summary":"","examples":[{"language":"mjs","displayName":null,"code":"const {\n  getHashes,\n} = await import('node:crypto');\n\nconsole.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]"},{"language":"cjs","displayName":null,"code":"const {\n  getHashes,\n} = require('node:crypto');\n\nconsole.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]"}],"children":[]},{"kind":"method","id":"cryptogetrandomvaluestypedarray","name":"getRandomValues","title":"`crypto.getRandomValues(typedArray)`","scope":"module","overloadOf":null,"stability":null,"added":["v17.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"typedArray","type":{"text":"Buffer | TypedArray | DataView | ArrayBuffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":33,"end":44}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer | TypedArray | DataView | ArrayBuffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":33,"end":44}]},"description":"Returns `typedArray`."}},"description":"A convenient alias for [`crypto.webcrypto.getRandomValues()`](webcrypto.html#cryptogetrandomvaluestypedarray). This\nimplementation is not compliant with the Web Crypto spec, to write\nweb-compatible code use [`crypto.webcrypto.getRandomValues()`](webcrypto.html#cryptogetrandomvaluestypedarray) instead.","summary":"A convenient alias for `crypto.webcrypto.getRandomValues()`. This implementation is not compliant with the Web Crypto spec, to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead.","examples":[],"children":[]},{"kind":"method","id":"cryptohashalgorithm-data-options","name":"hash","title":"`crypto.hash(algorithm, data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v21.7.0","v20.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/60994","commit":null,"description":"This API is no longer experimental."},{"versions":["v24.4.0"],"prUrl":"https://github.com/nodejs/node/pull/58121","commit":null,"description":"The `outputLength` option was added for XOF hash functions."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"When `data` is a\nstring, it will be encoded as UTF-8 before being hashed. If a different\ninput encoding is desired for a string input, user could encode the string\ninto a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing\nthe encoded `TypedArray` into this API instead.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"outputEncoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"[Encoding](buffer.html#buffers-and-character-encodings) used to encode the\nreturned digest.","default":"'hex'","optional":true,"rest":false,"properties":[]},{"name":"outputLength","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"For XOF hash functions such as 'shake256',\nthe outputLength option can be used to specify the desired output length in bytes.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":""}},"description":"A utility for creating one-shot hash digests of data. It can be faster than\nthe object-based `crypto.createHash()` when hashing a smaller amount of data\n(<= 5MB) that's readily available. If the data can be big or if it is streamed,\nit's still recommended to use `crypto.createHash()` instead.\n\nThe `algorithm` is dependent on the available algorithms supported by the\nversion of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.\nOn recent releases of OpenSSL, `openssl list -digest-algorithms` will\ndisplay the available digest algorithms.\n\nIf `options` is a string, then it specifies the `outputEncoding`.\n\nExample:\n\n```cjs\nconst crypto = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\n// Hashing a string and return the result as a hex-encoded string.\nconst string = 'Node.js';\n// 10b3493287f831e81a438811a1ffba01f8cec4b7\nconsole.log(crypto.hash('sha1', string));\n\n// Encode a base64-encoded string into a Buffer, hash it and return\n// the result as a buffer.\nconst base64 = 'Tm9kZS5qcw==';\n// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>\nconsole.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));\n```\n\n```mjs\nimport crypto from 'node:crypto';\nimport { Buffer } from 'node:buffer';\n\n// Hashing a string and return the result as a hex-encoded string.\nconst string = 'Node.js';\n// 10b3493287f831e81a438811a1ffba01f8cec4b7\nconsole.log(crypto.hash('sha1', string));\n\n// Encode a base64-encoded string into a Buffer, hash it and return\n// the result as a buffer.\nconst base64 = 'Tm9kZS5qcw==';\n// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>\nconsole.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));\n```","summary":"A utility for creating one-shot hash digests of data. It can be faster than the object-based `crypto.createHash()` when hashing a smaller amount of data (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use `crypto.createHash()` instead.","examples":[{"language":"cjs","displayName":null,"code":"const crypto = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\n// Hashing a string and return the result as a hex-encoded string.\nconst string = 'Node.js';\n// 10b3493287f831e81a438811a1ffba01f8cec4b7\nconsole.log(crypto.hash('sha1', string));\n\n// Encode a base64-encoded string into a Buffer, hash it and return\n// the result as a buffer.\nconst base64 = 'Tm9kZS5qcw==';\n// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>\nconsole.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));"},{"language":"mjs","displayName":null,"code":"import crypto from 'node:crypto';\nimport { Buffer } from 'node:buffer';\n\n// Hashing a string and return the result as a hex-encoded string.\nconst string = 'Node.js';\n// 10b3493287f831e81a438811a1ffba01f8cec4b7\nconsole.log(crypto.hash('sha1', string));\n\n// Encode a base64-encoded string into a Buffer, hash it and return\n// the result as a buffer.\nconst base64 = 'Tm9kZS5qcw==';\n// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>\nconsole.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));"}],"children":[]},{"kind":"method","id":"cryptohkdfdigest-ikm-salt-info-keylen-callback","name":"hkdf","title":"`crypto.hkdf(digest, ikm, salt, info, keylen, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.8.0","v16.18.0"],"prUrl":"https://github.com/nodejs/node/pull/44201","commit":null,"description":"The input keying material can now be zero-length."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"digest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The digest algorithm to use.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ikm","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65}]},"description":"The input\nkeying material. Must be provided but can be zero-length.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"The salt value. Must\nbe provided but can be zero-length.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"info","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"Additional info value.\nMust be provided but can be zero-length, and cannot be more than 1024 bytes.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The length of the key to generate. Must be greater than 0.\nThe maximum allowable value is `255` times the number of bytes produced by\nthe selected digest function (e.g. `sha512` generates 64-byte hashes, making\nthe maximum HKDF output 16320 bytes).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"derivedKey","type":{"text":"ArrayBuffer","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"HKDF is a simple key derivation function defined in RFC 5869. The given `ikm`,\n`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.\n\nThe supplied `callback` function is called with two arguments: `err` and\n`derivedKey`. If an error occurs while deriving the key, `err` will be set;\notherwise `err` will be `null`. The successfully generated `derivedKey` will\nbe passed to the callback as an {ArrayBuffer}. An error will be thrown if any\nof the input arguments specify invalid values or types.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst {\n  hkdf,\n} = await import('node:crypto');\n\nhkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n});\n```\n\n```cjs\nconst {\n  hkdf,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nhkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n});\n```","summary":"HKDF is a simple key derivation function defined in RFC 5869. The given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst {\n  hkdf,\n} = await import('node:crypto');\n\nhkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n});"},{"language":"cjs","displayName":null,"code":"const {\n  hkdf,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nhkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n});"}],"children":[]},{"kind":"method","id":"cryptohkdfsyncdigest-ikm-salt-info-keylen","name":"hkdfSync","title":"`crypto.hkdfSync(digest, ikm, salt, info, keylen)`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.8.0","v16.18.0"],"prUrl":"https://github.com/nodejs/node/pull/44201","commit":null,"description":"The input keying material can now be zero-length."}],"signature":{"parameters":[{"name":"digest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The digest algorithm to use.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ikm","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65}]},"description":"The input\nkeying material. Must be provided but can be zero-length.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"The salt value. Must\nbe provided but can be zero-length.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"info","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"Additional info value.\nMust be provided but can be zero-length, and cannot be more than 1024 bytes.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The length of the key to generate. Must be greater than 0.\nThe maximum allowable value is `255` times the number of bytes produced by\nthe selected digest function (e.g. `sha512` generates 64-byte hashes, making\nthe maximum HKDF output 16320 bytes).","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"ArrayBuffer","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11}]},"description":""}},"description":"Provides a synchronous HKDF key derivation function as defined in RFC 5869. The\ngiven `ikm`, `salt` and `info` are used with the `digest` to derive a key of\n`keylen` bytes.\n\nThe successfully generated `derivedKey` will be returned as an {ArrayBuffer}.\n\nAn error will be thrown if any of the input arguments specify invalid values or\ntypes, or if the derived key cannot be generated.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst {\n  hkdfSync,\n} = await import('node:crypto');\n\nconst derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);\nconsole.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n```\n\n```cjs\nconst {\n  hkdfSync,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);\nconsole.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'\n```","summary":"Provides a synchronous HKDF key derivation function as defined in RFC 5869. The given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst {\n  hkdfSync,\n} = await import('node:crypto');\n\nconst derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);\nconsole.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'"},{"language":"cjs","displayName":null,"code":"const {\n  hkdfSync,\n} = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);\nconsole.log(Buffer.from(derivedKey).toString('hex'));  // '24156e2...5391653'"}],"children":[]},{"kind":"method","id":"cryptopbkdf2password-salt-iterations-keylen-digest-callback","name":"pbkdf2","title":"`crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The password and salt arguments can also be ArrayBuffer instances."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/30578","commit":null,"description":"The `iterations` parameter is now restricted to positive values. Earlier releases treated other values as one."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11305","commit":null,"description":"The `digest` parameter is always required now."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/4047","commit":null,"description":"Calling this function without passing the `digest` parameter is deprecated now and will emit a warning."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default encoding for `password` if it is a string changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"password","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"iterations","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"digest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"derivedKey","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)\nimplementation. A selected HMAC digest algorithm specified by `digest` is\napplied to derive a key of the requested byte length (`keylen`) from the\n`password`, `salt` and `iterations`.\n\nThe supplied `callback` function is called with two arguments: `err` and\n`derivedKey`. If an error occurs while deriving the key, `err` will be set;\notherwise `err` will be `null`. By default, the successfully generated\n`derivedKey` will be passed to the callback as a [`Buffer`](buffer.html). An error will be\nthrown if any of the input arguments specify invalid values or types.\n\nThe `iterations` argument must be a number set as high as possible. The\nhigher the number of iterations, the more secure the derived key will be,\nbut will take a longer amount of time to complete.\n\nThe `salt` should be as unique as possible. It is recommended that a salt is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `password` or `salt`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\n```mjs\nconst {\n  pbkdf2,\n} = await import('node:crypto');\n\npbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n```\n\n```cjs\nconst {\n  pbkdf2,\n} = require('node:crypto');\n\npbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n```\n\nAn array of supported digest functions can be retrieved using\n[`crypto.getHashes()`](#cryptogethashes).\n\nThis API uses libuv's threadpool, which can have surprising and\nnegative performance implications for some applications; see the\n[`UV_THREADPOOL_SIZE`](cli.html#uv_threadpool_sizesize) documentation for more information.","summary":"Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  pbkdf2,\n} = await import('node:crypto');\n\npbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});"},{"language":"cjs","displayName":null,"code":"const {\n  pbkdf2,\n} = require('node:crypto');\n\npbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});"}],"children":[]},{"kind":"method","id":"cryptopbkdf2syncpassword-salt-iterations-keylen-digest","name":"pbkdf2Sync","title":"`crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The password and salt arguments can also be ArrayBuffer instances."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/30578","commit":null,"description":"The `iterations` parameter is now restricted to positive values. Earlier releases treated other values as one."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/4047","commit":null,"description":"Calling this function without passing the `digest` parameter is deprecated now and will emit a warning."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5522","commit":null,"description":"The default encoding for `password` if it is a string changed from `binary` to `utf8`."}],"signature":{"parameters":[{"name":"password","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"iterations","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"digest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)\nimplementation. A selected HMAC digest algorithm specified by `digest` is\napplied to derive a key of the requested byte length (`keylen`) from the\n`password`, `salt` and `iterations`.\n\nIf an error occurs an `Error` will be thrown, otherwise the derived key will be\nreturned as a [`Buffer`](buffer.html).\n\nThe `iterations` argument must be a number set as high as possible. The\nhigher the number of iterations, the more secure the derived key will be,\nbut will take a longer amount of time to complete.\n\nThe `salt` should be as unique as possible. It is recommended that a salt is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `password` or `salt`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\n```mjs\nconst {\n  pbkdf2Sync,\n} = await import('node:crypto');\n\nconst key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');\nconsole.log(key.toString('hex'));  // '3745e48...08d59ae'\n```\n\n```cjs\nconst {\n  pbkdf2Sync,\n} = require('node:crypto');\n\nconst key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');\nconsole.log(key.toString('hex'));  // '3745e48...08d59ae'\n```\n\nAn array of supported digest functions can be retrieved using\n[`crypto.getHashes()`](#cryptogethashes).","summary":"Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  pbkdf2Sync,\n} = await import('node:crypto');\n\nconst key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');\nconsole.log(key.toString('hex'));  // '3745e48...08d59ae'"},{"language":"cjs","displayName":null,"code":"const {\n  pbkdf2Sync,\n} = require('node:crypto');\n\nconst key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');\nconsole.log(key.toString('hex'));  // '3745e48...08d59ae'"}],"children":[]},{"kind":"method","id":"cryptoprivatedecryptprivatekey-buffer","name":"privateDecrypt","title":"`crypto.privateDecrypt(privateKey, buffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/65073","commit":null,"description":"The `mgf1Hash` option was added."},{"versions":["v21.6.2","v20.11.1","v18.19.1"],"prUrl":"https://github.com/nodejs-private/node-private/pull/515","commit":null,"description":"The `RSA_PKCS1_PADDING` padding was disabled unless the OpenSSL build supports implicit rejection."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"Added string, ArrayBuffer, and CryptoKey as allowable key types. The oaepLabel can be an ArrayBuffer. The buffer can be a string or ArrayBuffer. All types that accept buffers are limited to a maximum of 2 ** 31 - 1 bytes."},{"versions":["v12.11.0"],"prUrl":"https://github.com/nodejs/node/pull/29489","commit":null,"description":"The `oaepLabel` option was added."},{"versions":["v12.9.0"],"prUrl":"https://github.com/nodejs/node/pull/28335","commit":null,"description":"The `oaepHash` option was added."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"This function now supports key objects."}],"signature":{"parameters":[{"name":"privateKey","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86},{"name":"URL","href":"url.html#the-whatwg-url-api","start":89,"end":92}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"oaepHash","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The hash function to use for OAEP padding and, unless\n`mgf1Hash` is set, MGF1.","default":"'sha1'","optional":true,"rest":false,"properties":[]},{"name":"mgf1Hash","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The hash function to use for the MGF1 mask generation\nfunction of OAEP padding. If not specified, the value of `oaepHash` is used.\nThis allows the OAEP digest and the MGF1 digest to differ.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"oaepLabel","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"The label to\nuse for OAEP padding. If not specified, no label is used.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"crypto.constants","links":[{"name":"crypto.constants","href":"crypto.html#cryptoconstants","start":0,"end":16}]},"description":"An optional padding value defined in\n`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,\n`crypto.constants.RSA_PKCS1_PADDING`, or\n`crypto.constants.RSA_PKCS1_OAEP_PADDING`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A new `Buffer` with the decrypted content."}},"description":"Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using\nthe corresponding public key, for example using [`crypto.publicEncrypt()`](#cryptopublicencryptkey-buffer).\n\nIf `privateKey` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`privateKey` had been passed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey). If it is an\nobject, the `padding` property can be passed. Otherwise, this function uses\n`RSA_PKCS1_OAEP_PADDING`.\n\nUsing `crypto.constants.RSA_PKCS1_PADDING` in [`crypto.privateDecrypt()`](#cryptoprivatedecryptprivatekey-buffer)\nrequires OpenSSL to support implicit rejection (`rsa_pkcs1_implicit_rejection`).\nIf the version of OpenSSL used by Node.js does not support this feature,\nattempting to use `RSA_PKCS1_PADDING` will fail.","summary":"Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using the corresponding public key, for example using `crypto.publicEncrypt()`.","examples":[],"children":[]},{"kind":"method","id":"cryptoprivateencryptprivatekey-buffer","name":"privateEncrypt","title":"`crypto.privateEncrypt(privateKey, buffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v1.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"Added string, ArrayBuffer, and CryptoKey as allowable key types. The passphrase can be an ArrayBuffer. The buffer can be a string or ArrayBuffer. All types that accept buffers are limited to a maximum of 2 ** 31 - 1 bytes."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"This function now supports key objects."}],"signature":{"parameters":[{"name":"privateKey","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86},{"name":"URL","href":"url.html#the-whatwg-url-api","start":89,"end":92}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":68,"end":77},{"name":"URL","href":"url.html#the-whatwg-url-api","start":80,"end":83}]},"description":"The private key material, a {KeyObject}, or a {URL} referencing an object\nfor an OpenSSL STORE loader.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"passphrase","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"An optional\npassphrase for the private key.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"crypto.constants","links":[{"name":"crypto.constants","href":"crypto.html#cryptoconstants","start":0,"end":16}]},"description":"An optional padding value defined in\n`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or\n`crypto.constants.RSA_PKCS1_PADDING`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `buffer`, `key`,\nor `passphrase` are strings.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A new `Buffer` with the encrypted content."}},"description":"Encrypts `buffer` with `privateKey`. The returned data can be decrypted using\nthe corresponding public key, for example using [`crypto.publicDecrypt()`](#cryptopublicdecryptkey-buffer).\n\nIf `privateKey` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`privateKey` had been passed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey). If it is an\nobject, the `padding` property can be passed. Otherwise, this function uses\n`RSA_PKCS1_PADDING`.","summary":"Encrypts `buffer` with `privateKey`. The returned data can be decrypted using the corresponding public key, for example using `crypto.publicDecrypt()`.","examples":[],"children":[]},{"kind":"method","id":"cryptopublicdecryptkey-buffer","name":"publicDecrypt","title":"`crypto.publicDecrypt(key, buffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v1.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"Added string, ArrayBuffer, and CryptoKey as allowable key types. The passphrase can be an ArrayBuffer. The buffer can be a string or ArrayBuffer. All types that accept buffers are limited to a maximum of 2 ** 31 - 1 bytes."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"This function now supports key objects."}],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"passphrase","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"An optional\npassphrase for the private key.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"crypto.constants","links":[{"name":"crypto.constants","href":"crypto.html#cryptoconstants","start":0,"end":16}]},"description":"An optional padding value defined in\n`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or\n`crypto.constants.RSA_PKCS1_PADDING`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `buffer`, `key`,\nor `passphrase` are strings.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A new `Buffer` with the decrypted content."}},"description":"Decrypts `buffer` with `key`. `buffer` was previously encrypted using\nthe corresponding private key, for example using [`crypto.privateEncrypt()`](#cryptoprivateencryptprivatekey-buffer).\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`key` had been passed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey). If it is an\nobject, the `padding` property can be passed. Otherwise, this function uses\n`RSA_PKCS1_PADDING`.\n\nBecause RSA public keys can be derived from private keys, a private key may\nbe passed instead of a public key.","summary":"Decrypts `buffer` with `key`. `buffer` was previously encrypted using the corresponding private key, for example using `crypto.privateEncrypt()`.","examples":[],"children":[]},{"kind":"method","id":"cryptopublicencryptkey-buffer","name":"publicEncrypt","title":"`crypto.publicEncrypt(key, buffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.14"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/65073","commit":null,"description":"The `mgf1Hash` option was added."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"Added string, ArrayBuffer, and CryptoKey as allowable key types. The oaepLabel and passphrase can be ArrayBuffers. The buffer can be a string or ArrayBuffer. All types that accept buffers are limited to a maximum of 2 ** 31 - 1 bytes."},{"versions":["v12.11.0"],"prUrl":"https://github.com/nodejs/node/pull/29489","commit":null,"description":"The `oaepLabel` option was added."},{"versions":["v12.9.0"],"prUrl":"https://github.com/nodejs/node/pull/28335","commit":null,"description":"The `oaepHash` option was added."},{"versions":["v11.6.0"],"prUrl":"https://github.com/nodejs/node/pull/24234","commit":null,"description":"This function now supports key objects."}],"signature":{"parameters":[{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"key","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":56,"end":65},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":68,"end":77}]},"description":"A PEM encoded public or private key, {KeyObject}, or {CryptoKey}.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"oaepHash","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The hash function to use for OAEP padding and, unless\n`mgf1Hash` is set, MGF1.","default":"'sha1'","optional":true,"rest":false,"properties":[]},{"name":"mgf1Hash","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The hash function to use for the MGF1 mask generation\nfunction of OAEP padding. If not specified, the value of `oaepHash` is used.\nThis allows the OAEP digest and the MGF1 digest to differ.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"oaepLabel","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"The label to\nuse for OAEP padding. If not specified, no label is used.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"passphrase","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"An optional\npassphrase for the private key.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"padding","type":{"text":"crypto.constants","links":[{"name":"crypto.constants","href":"crypto.html#cryptoconstants","start":0,"end":16}]},"description":"An optional padding value defined in\n`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,\n`crypto.constants.RSA_PKCS1_PADDING`, or\n`crypto.constants.RSA_PKCS1_OAEP_PADDING`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The string encoding to use when `buffer`, `key`,\n`oaepLabel`, or `passphrase` are strings.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"buffer","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A new `Buffer` with the encrypted content."}},"description":"Encrypts the content of `buffer` with `key` and returns a new\n[`Buffer`](buffer.html) with encrypted content. The returned data can be decrypted using\nthe corresponding private key, for example using [`crypto.privateDecrypt()`](#cryptoprivatedecryptprivatekey-buffer).\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if\n`key` had been passed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey). If it is an\nobject, the `padding` property can be passed. Otherwise, this function uses\n`RSA_PKCS1_OAEP_PADDING`.\n\nBecause RSA public keys can be derived from private keys, a private key may\nbe passed instead of a public key.","summary":"Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using the corresponding private key, for example using `crypto.privateDecrypt()`.","examples":[],"children":[]},{"kind":"method","id":"cryptorandombytessize-callback","name":"randomBytes","title":"`crypto.randomBytes(size[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v9.0.0"],"prUrl":"https://github.com/nodejs/node/pull/16454","commit":null,"description":"Passing `null` as the `callback` argument now throws `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"size","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes to generate.  The `size` must\nnot be larger than `2**31 - 1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buf","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"if the `callback` function is not provided."}},"description":"Generates cryptographically strong pseudorandom data. The `size` argument\nis a number indicating the number of bytes to generate.\n\nIf a `callback` function is provided, the bytes are generated asynchronously\nand the `callback` function is invoked with two arguments: `err` and `buf`.\nIf an error occurs, `err` will be an `Error` object; otherwise it is `null`. The\n`buf` argument is a [`Buffer`](buffer.html) containing the generated bytes.\n\n```mjs\n// Asynchronous\nconst {\n  randomBytes,\n} = await import('node:crypto');\n\nrandomBytes(256, (err, buf) => {\n  if (err) throw err;\n  console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);\n});\n```\n\n```cjs\n// Asynchronous\nconst {\n  randomBytes,\n} = require('node:crypto');\n\nrandomBytes(256, (err, buf) => {\n  if (err) throw err;\n  console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);\n});\n```\n\nIf the `callback` function is not provided, the random bytes are generated\nsynchronously and returned as a [`Buffer`](buffer.html). An error will be thrown if\nthere is a problem generating the bytes.\n\n```mjs\n// Synchronous\nconst {\n  randomBytes,\n} = await import('node:crypto');\n\nconst buf = randomBytes(256);\nconsole.log(\n  `${buf.length} bytes of random data: ${buf.toString('hex')}`);\n```\n\n```cjs\n// Synchronous\nconst {\n  randomBytes,\n} = require('node:crypto');\n\nconst buf = randomBytes(256);\nconsole.log(\n  `${buf.length} bytes of random data: ${buf.toString('hex')}`);\n```\n\nThe `crypto.randomBytes()` method will not complete until there is\nsufficient entropy available.\nThis should normally never take longer than a few milliseconds. The only time\nwhen generating the random bytes may conceivably block for a longer period of\ntime is right after boot, when the whole system is still low on entropy.\n\nThis API uses libuv's threadpool, which can have surprising and\nnegative performance implications for some applications; see the\n[`UV_THREADPOOL_SIZE`](cli.html#uv_threadpool_sizesize) documentation for more information.\n\nThe asynchronous version of `crypto.randomBytes()` is carried out in a single\nthreadpool request. To minimize threadpool task length variation, partition\nlarge `randomBytes` requests when doing so as part of fulfilling a client\nrequest.","summary":"Generates cryptographically strong pseudorandom data. The `size` argument is a number indicating the number of bytes to generate.","examples":[{"language":"mjs","displayName":null,"code":"// Asynchronous\nconst {\n  randomBytes,\n} = await import('node:crypto');\n\nrandomBytes(256, (err, buf) => {\n  if (err) throw err;\n  console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);\n});"},{"language":"cjs","displayName":null,"code":"// Asynchronous\nconst {\n  randomBytes,\n} = require('node:crypto');\n\nrandomBytes(256, (err, buf) => {\n  if (err) throw err;\n  console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);\n});"},{"language":"mjs","displayName":null,"code":"// Synchronous\nconst {\n  randomBytes,\n} = await import('node:crypto');\n\nconst buf = randomBytes(256);\nconsole.log(\n  `${buf.length} bytes of random data: ${buf.toString('hex')}`);"},{"language":"cjs","displayName":null,"code":"// Synchronous\nconst {\n  randomBytes,\n} = require('node:crypto');\n\nconst buf = randomBytes(256);\nconsole.log(\n  `${buf.length} bytes of random data: ${buf.toString('hex')}`);"}],"children":[]},{"kind":"method","id":"cryptorandomfillbuffer-offset-size-callback","name":"randomFill","title":"`crypto.randomFill(buffer[, offset][, size], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v7.10.0","v6.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v9.0.0"],"prUrl":"https://github.com/nodejs/node/pull/15231","commit":null,"description":"The `buffer` argument may be any `TypedArray` or `DataView`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"Must be supplied. The\nsize of the provided `buffer` must not be larger than `2**31 - 1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The start position, in elements for a `TypedArray` and in\nbytes for an `ArrayBuffer` or `DataView`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"size","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The amount to fill, in the same units as `offset`.","default":"buffer.length - offset` for a `TypedArray`, or `buffer.byteLength - offset` for an `ArrayBuffer` or `DataView`. The `size` must not be larger than `2**31 - 1","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"`function(err, buf) {}`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"This function is similar to [`crypto.randomBytes()`](#cryptorandombytessize-callback) but requires the first\nargument to be a [`Buffer`](buffer.html) that will be filled. It also\nrequires that a callback is passed in.\n\nIf the `callback` function is not provided, an error will be thrown.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst { randomFill } = await import('node:crypto');\n\nconst buf = Buffer.alloc(10);\nrandomFill(buf, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\nrandomFill(buf, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\n// The above is equivalent to the following:\nrandomFill(buf, 5, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n```\n\n```cjs\nconst { randomFill } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(10);\nrandomFill(buf, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\nrandomFill(buf, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\n// The above is equivalent to the following:\nrandomFill(buf, 5, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n```\n\nAny `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as\n`buffer`.\n\nWhile this includes instances of `Float32Array` and `Float64Array`, this\nfunction should not be used to generate random floating-point numbers. The\nresult may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array\ncontains finite numbers only, they are not drawn from a uniform random\ndistribution and have no meaningful lower or upper bounds.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst { randomFill } = await import('node:crypto');\n\nconst a = new Uint32Array(10);\nrandomFill(a, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst b = new DataView(new ArrayBuffer(10));\nrandomFill(b, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst c = new ArrayBuffer(10);\nrandomFill(c, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf).toString('hex'));\n});\n```\n\n```cjs\nconst { randomFill } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst a = new Uint32Array(10);\nrandomFill(a, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst b = new DataView(new ArrayBuffer(10));\nrandomFill(b, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst c = new ArrayBuffer(10);\nrandomFill(c, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf).toString('hex'));\n});\n```\n\nThis API uses libuv's threadpool, which can have surprising and\nnegative performance implications for some applications; see the\n[`UV_THREADPOOL_SIZE`](cli.html#uv_threadpool_sizesize) documentation for more information.\n\nThe asynchronous version of `crypto.randomFill()` is carried out in a single\nthreadpool request. To minimize threadpool task length variation, partition\nlarge `randomFill` requests when doing so as part of fulfilling a client\nrequest.","summary":"This function is similar to `crypto.randomBytes()` but requires the first argument to be a `Buffer` that will be filled. It also requires that a callback is passed in.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { randomFill } = await import('node:crypto');\n\nconst buf = Buffer.alloc(10);\nrandomFill(buf, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\nrandomFill(buf, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\n// The above is equivalent to the following:\nrandomFill(buf, 5, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});"},{"language":"cjs","displayName":null,"code":"const { randomFill } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(10);\nrandomFill(buf, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\nrandomFill(buf, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});\n\n// The above is equivalent to the following:\nrandomFill(buf, 5, 5, (err, buf) => {\n  if (err) throw err;\n  console.log(buf.toString('hex'));\n});"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { randomFill } = await import('node:crypto');\n\nconst a = new Uint32Array(10);\nrandomFill(a, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst b = new DataView(new ArrayBuffer(10));\nrandomFill(b, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst c = new ArrayBuffer(10);\nrandomFill(c, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf).toString('hex'));\n});"},{"language":"cjs","displayName":null,"code":"const { randomFill } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst a = new Uint32Array(10);\nrandomFill(a, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst b = new DataView(new ArrayBuffer(10));\nrandomFill(b, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n    .toString('hex'));\n});\n\nconst c = new ArrayBuffer(10);\nrandomFill(c, (err, buf) => {\n  if (err) throw err;\n  console.log(Buffer.from(buf).toString('hex'));\n});"}],"children":[]},{"kind":"method","id":"cryptorandomfillsyncbuffer-offset-size","name":"randomFillSync","title":"`crypto.randomFillSync(buffer[, offset][, size])`","scope":"module","overloadOf":null,"stability":null,"added":["v7.10.0","v6.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v9.0.0"],"prUrl":"https://github.com/nodejs/node/pull/15231","commit":null,"description":"The `buffer` argument may be any `TypedArray` or `DataView`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"Must be supplied. The\nsize of the provided `buffer` must not be larger than `2**31 - 1`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The start position, in elements for a `TypedArray` and in\nbytes for an `ArrayBuffer` or `DataView`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"size","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The amount to fill, in the same units as `offset`.","default":"buffer.length - offset` for a `TypedArray`, or `buffer.byteLength - offset` for an `ArrayBuffer` or `DataView`. The `size` must not be larger than `2**31 - 1","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"The object passed as\n`buffer` argument."}},"description":"Synchronous version of [`crypto.randomFill()`](#cryptorandomfillbuffer-offset-size-callback).\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst { randomFillSync } = await import('node:crypto');\n\nconst buf = Buffer.alloc(10);\nconsole.log(randomFillSync(buf).toString('hex'));\n\nrandomFillSync(buf, 5);\nconsole.log(buf.toString('hex'));\n\n// The above is equivalent to the following:\nrandomFillSync(buf, 5, 5);\nconsole.log(buf.toString('hex'));\n```\n\n```cjs\nconst { randomFillSync } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(10);\nconsole.log(randomFillSync(buf).toString('hex'));\n\nrandomFillSync(buf, 5);\nconsole.log(buf.toString('hex'));\n\n// The above is equivalent to the following:\nrandomFillSync(buf, 5, 5);\nconsole.log(buf.toString('hex'));\n```\n\nAny `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as\n`buffer`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst { randomFillSync } = await import('node:crypto');\n\nconst a = new Uint32Array(10);\nconsole.log(Buffer.from(randomFillSync(a).buffer,\n                        a.byteOffset, a.byteLength).toString('hex'));\n\nconst b = new DataView(new ArrayBuffer(10));\nconsole.log(Buffer.from(randomFillSync(b).buffer,\n                        b.byteOffset, b.byteLength).toString('hex'));\n\nconst c = new ArrayBuffer(10);\nconsole.log(Buffer.from(randomFillSync(c)).toString('hex'));\n```\n\n```cjs\nconst { randomFillSync } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst a = new Uint32Array(10);\nconsole.log(Buffer.from(randomFillSync(a).buffer,\n                        a.byteOffset, a.byteLength).toString('hex'));\n\nconst b = new DataView(new ArrayBuffer(10));\nconsole.log(Buffer.from(randomFillSync(b).buffer,\n                        b.byteOffset, b.byteLength).toString('hex'));\n\nconst c = new ArrayBuffer(10);\nconsole.log(Buffer.from(randomFillSync(c)).toString('hex'));\n```","summary":"Synchronous version of `crypto.randomFill()`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { randomFillSync } = await import('node:crypto');\n\nconst buf = Buffer.alloc(10);\nconsole.log(randomFillSync(buf).toString('hex'));\n\nrandomFillSync(buf, 5);\nconsole.log(buf.toString('hex'));\n\n// The above is equivalent to the following:\nrandomFillSync(buf, 5, 5);\nconsole.log(buf.toString('hex'));"},{"language":"cjs","displayName":null,"code":"const { randomFillSync } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(10);\nconsole.log(randomFillSync(buf).toString('hex'));\n\nrandomFillSync(buf, 5);\nconsole.log(buf.toString('hex'));\n\n// The above is equivalent to the following:\nrandomFillSync(buf, 5, 5);\nconsole.log(buf.toString('hex'));"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst { randomFillSync } = await import('node:crypto');\n\nconst a = new Uint32Array(10);\nconsole.log(Buffer.from(randomFillSync(a).buffer,\n                        a.byteOffset, a.byteLength).toString('hex'));\n\nconst b = new DataView(new ArrayBuffer(10));\nconsole.log(Buffer.from(randomFillSync(b).buffer,\n                        b.byteOffset, b.byteLength).toString('hex'));\n\nconst c = new ArrayBuffer(10);\nconsole.log(Buffer.from(randomFillSync(c)).toString('hex'));"},{"language":"cjs","displayName":null,"code":"const { randomFillSync } = require('node:crypto');\nconst { Buffer } = require('node:buffer');\n\nconst a = new Uint32Array(10);\nconsole.log(Buffer.from(randomFillSync(a).buffer,\n                        a.byteOffset, a.byteLength).toString('hex'));\n\nconst b = new DataView(new ArrayBuffer(10));\nconsole.log(Buffer.from(randomFillSync(b).buffer,\n                        b.byteOffset, b.byteLength).toString('hex'));\n\nconst c = new ArrayBuffer(10);\nconsole.log(Buffer.from(randomFillSync(c)).toString('hex'));"}],"children":[]},{"kind":"method","id":"cryptorandomintmin-max-callback","name":"randomInt","title":"`crypto.randomInt([min, ]max[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v14.10.0","v12.19.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"min","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Start of random range (inclusive).","default":"0","optional":true,"rest":false,"properties":[]},{"name":"max","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"End of random range (exclusive).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"`function(err, n) {}`.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Return a random integer `n` such that `min <= n < max`.  This\nimplementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).\n\nThe range (`max - min`) must be less than 2<sup>48</sup>. `min` and `max` must\nbe [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).\n\nIf the `callback` function is not provided, the random integer is\ngenerated synchronously.\n\n```mjs\n// Asynchronous\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nrandomInt(3, (err, n) => {\n  if (err) throw err;\n  console.log(`Random number chosen from (0, 1, 2): ${n}`);\n});\n```\n\n```cjs\n// Asynchronous\nconst {\n  randomInt,\n} = require('node:crypto');\n\nrandomInt(3, (err, n) => {\n  if (err) throw err;\n  console.log(`Random number chosen from (0, 1, 2): ${n}`);\n});\n```\n\n```mjs\n// Synchronous\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nconst n = randomInt(3);\nconsole.log(`Random number chosen from (0, 1, 2): ${n}`);\n```\n\n```cjs\n// Synchronous\nconst {\n  randomInt,\n} = require('node:crypto');\n\nconst n = randomInt(3);\nconsole.log(`Random number chosen from (0, 1, 2): ${n}`);\n```\n\n```mjs\n// With `min` argument\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nconst n = randomInt(1, 7);\nconsole.log(`The dice rolled: ${n}`);\n```\n\n```cjs\n// With `min` argument\nconst {\n  randomInt,\n} = require('node:crypto');\n\nconst n = randomInt(1, 7);\nconsole.log(`The dice rolled: ${n}`);\n```","summary":"Return a random integer `n` such that `min <= n < max`.  This implementation avoids modulo bias.","examples":[{"language":"mjs","displayName":null,"code":"// Asynchronous\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nrandomInt(3, (err, n) => {\n  if (err) throw err;\n  console.log(`Random number chosen from (0, 1, 2): ${n}`);\n});"},{"language":"cjs","displayName":null,"code":"// Asynchronous\nconst {\n  randomInt,\n} = require('node:crypto');\n\nrandomInt(3, (err, n) => {\n  if (err) throw err;\n  console.log(`Random number chosen from (0, 1, 2): ${n}`);\n});"},{"language":"mjs","displayName":null,"code":"// Synchronous\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nconst n = randomInt(3);\nconsole.log(`Random number chosen from (0, 1, 2): ${n}`);"},{"language":"cjs","displayName":null,"code":"// Synchronous\nconst {\n  randomInt,\n} = require('node:crypto');\n\nconst n = randomInt(3);\nconsole.log(`Random number chosen from (0, 1, 2): ${n}`);"},{"language":"mjs","displayName":null,"code":"// With `min` argument\nconst {\n  randomInt,\n} = await import('node:crypto');\n\nconst n = randomInt(1, 7);\nconsole.log(`The dice rolled: ${n}`);"},{"language":"cjs","displayName":null,"code":"// With `min` argument\nconst {\n  randomInt,\n} = require('node:crypto');\n\nconst n = randomInt(1, 7);\nconsole.log(`The dice rolled: ${n}`);"}],"children":[]},{"kind":"method","id":"cryptorandomuuidoptions","name":"randomUUID","title":"`crypto.randomUUID([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0","v14.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"disableEntropyCache","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"By default, to improve performance,\nNode.js generates and caches enough\nrandom data to generate up to 128 random UUIDs. To generate a UUID\nwithout using the cache, set `disableEntropyCache` to `true`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a\ncryptographic pseudorandom number generator.","summary":"Generates a random RFC 4122 version 4 UUID. The UUID is generated using a cryptographic pseudorandom number generator.","examples":[],"children":[]},{"kind":"method","id":"cryptorandomuuidv7options","name":"randomUUIDv7","title":"`crypto.randomUUIDv7([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"disableEntropyCache","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"By default, to improve performance,\nNode.js generates and caches enough\nrandom data to generate up to 128 random UUIDs. To generate a UUID\nwithout using the cache, set `disableEntropyCache` to `true`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Generates a random [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.txt) version 7 UUID. The UUID contains a millisecond\nprecision Unix timestamp in the most significant 48 bits, followed by\ncryptographically secure random bits for the remaining fields, making it\nsuitable for use as a database key with time-based sorting. The embedded\ntimestamp relies on a non-monotonic clock and is not guaranteed to be strictly\nincreasing.","summary":"Generates a random RFC 9562 version 7 UUID. The UUID contains a millisecond precision Unix timestamp in the most significant 48 bits, followed by cryptographically secure random bits for the remaining fields, making it suitable for use as a database key with time-based sorting. The embedded timestamp relies on a non-monotonic clock and is not guaranteed to be strictly increasing.","examples":[],"children":[]},{"kind":"method","id":"cryptoscryptpassword-salt-keylen-options-callback","name":"scrypt","title":"`crypto.scrypt(password, salt, keylen[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The password and salt arguments can also be ArrayBuffer instances."},{"versions":["v12.8.0","v10.17.0"],"prUrl":"https://github.com/nodejs/node/pull/28799","commit":null,"description":"The `maxmem` value can now be any safe integer."},{"versions":["v10.9.0"],"prUrl":"https://github.com/nodejs/node/pull/21525","commit":null,"description":"The `cost`, `blockSize` and `parallelization` option names have been added."}],"signature":{"parameters":[{"name":"password","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"Buffer","href":"buffer.html#class-buffer","start":23,"end":29},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":32,"end":42},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":45,"end":53}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"cost","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"CPU/memory cost parameter. Must be a power of two greater\nthan one.","default":"16384","optional":true,"rest":false,"properties":[]},{"name":"blockSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Block size parameter.","default":"8","optional":true,"rest":false,"properties":[]},{"name":"parallelization","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Parallelization parameter.","default":"1","optional":true,"rest":false,"properties":[]},{"name":"N","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `cost`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"r","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `blockSize`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"p","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `parallelization`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"maxmem","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Memory upper bound. It is an error when (approximately)\n`128 * N * r > maxmem`.","default":"32 * 1024 * 1024","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"derivedKey","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Provides an asynchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based\nkey derivation function that is designed to be expensive computationally and\nmemory-wise in order to make brute-force attacks unrewarding.\n\nThe `salt` should be as unique as possible. It is recommended that a salt is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `password` or `salt`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nThe `callback` function is called with two arguments: `err` and `derivedKey`.\n`err` is an exception object when key derivation fails, otherwise `err` is\n`null`. `derivedKey` is passed to the callback as a [`Buffer`](buffer.html).\n\nAn exception is thrown when any of the input arguments specify invalid values\nor types.\n\n```mjs\nconst {\n  scrypt,\n} = await import('node:crypto');\n\n// Using the factory defaults.\nscrypt('password', 'salt', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n// Using a custom N parameter. Must be a power of two.\nscrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...aa39b34'\n});\n```\n\n```cjs\nconst {\n  scrypt,\n} = require('node:crypto');\n\n// Using the factory defaults.\nscrypt('password', 'salt', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n// Using a custom N parameter. Must be a power of two.\nscrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...aa39b34'\n});\n```","summary":"Provides an asynchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  scrypt,\n} = await import('node:crypto');\n\n// Using the factory defaults.\nscrypt('password', 'salt', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n// Using a custom N parameter. Must be a power of two.\nscrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...aa39b34'\n});"},{"language":"cjs","displayName":null,"code":"const {\n  scrypt,\n} = require('node:crypto');\n\n// Using the factory defaults.\nscrypt('password', 'salt', 64, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...08d59ae'\n});\n// Using a custom N parameter. Must be a power of two.\nscrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {\n  if (err) throw err;\n  console.log(derivedKey.toString('hex'));  // '3745e48...aa39b34'\n});"}],"children":[]},{"kind":"method","id":"cryptoscryptsyncpassword-salt-keylen-options","name":"scryptSync","title":"`crypto.scryptSync(password, salt, keylen[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v12.8.0","v10.17.0"],"prUrl":"https://github.com/nodejs/node/pull/28799","commit":null,"description":"The `maxmem` value can now be any safe integer."},{"versions":["v10.9.0"],"prUrl":"https://github.com/nodejs/node/pull/21525","commit":null,"description":"The `cost`, `blockSize` and `parallelization` option names have been added."}],"signature":{"parameters":[{"name":"password","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"salt","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"keylen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"cost","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"CPU/memory cost parameter. Must be a power of two greater\nthan one.","default":"16384","optional":true,"rest":false,"properties":[]},{"name":"blockSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Block size parameter.","default":"8","optional":true,"rest":false,"properties":[]},{"name":"parallelization","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Parallelization parameter.","default":"1","optional":true,"rest":false,"properties":[]},{"name":"N","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `cost`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"r","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `blockSize`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"p","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Alias for `parallelization`. Only one of both may be specified.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"maxmem","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Memory upper bound. It is an error when (approximately)\n`128 * N * r > maxmem`.","default":"32 * 1024 * 1024","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based\nkey derivation function that is designed to be expensive computationally and\nmemory-wise in order to make brute-force attacks unrewarding.\n\nThe `salt` should be as unique as possible. It is recommended that a salt is\nrandom and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.\n\nWhen passing strings for `password` or `salt`, please consider\n[caveats when using strings as inputs to cryptographic APIs](#using-strings-as-inputs-to-cryptographic-apis).\n\nAn exception is thrown when key derivation fails, otherwise the derived key is\nreturned as a [`Buffer`](buffer.html).\n\nAn exception is thrown when any of the input arguments specify invalid values\nor types.\n\n```mjs\nconst {\n  scryptSync,\n} = await import('node:crypto');\n// Using the factory defaults.\n\nconst key1 = scryptSync('password', 'salt', 64);\nconsole.log(key1.toString('hex'));  // '3745e48...08d59ae'\n// Using a custom N parameter. Must be a power of two.\nconst key2 = scryptSync('password', 'salt', 64, { N: 1024 });\nconsole.log(key2.toString('hex'));  // '3745e48...aa39b34'\n```\n\n```cjs\nconst {\n  scryptSync,\n} = require('node:crypto');\n// Using the factory defaults.\n\nconst key1 = scryptSync('password', 'salt', 64);\nconsole.log(key1.toString('hex'));  // '3745e48...08d59ae'\n// Using a custom N parameter. Must be a power of two.\nconst key2 = scryptSync('password', 'salt', 64, { N: 1024 });\nconsole.log(key2.toString('hex'));  // '3745e48...aa39b34'\n```","summary":"Provides a synchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.","examples":[{"language":"mjs","displayName":null,"code":"const {\n  scryptSync,\n} = await import('node:crypto');\n// Using the factory defaults.\n\nconst key1 = scryptSync('password', 'salt', 64);\nconsole.log(key1.toString('hex'));  // '3745e48...08d59ae'\n// Using a custom N parameter. Must be a power of two.\nconst key2 = scryptSync('password', 'salt', 64, { N: 1024 });\nconsole.log(key2.toString('hex'));  // '3745e48...aa39b34'"},{"language":"cjs","displayName":null,"code":"const {\n  scryptSync,\n} = require('node:crypto');\n// Using the factory defaults.\n\nconst key1 = scryptSync('password', 'salt', 64);\nconsole.log(key1.toString('hex'));  // '3745e48...08d59ae'\n// Using a custom N parameter. Must be a power of two.\nconst key2 = scryptSync('password', 'salt', 64, { N: 1024 });\nconsole.log(key2.toString('hex'));  // '3745e48...aa39b34'"}],"children":[]},{"kind":"method","id":"cryptosecureheapused","name":"secureHeapUsed","title":"`crypto.secureHeapUsed()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":""}},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"cryptosetengineengine-flags","name":"setEngine","title":"`crypto.setEngine(engine[, flags])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.11"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.4.0","v20.16.0"],"prUrl":"https://github.com/nodejs/node/pull/53329","commit":null,"description":"Custom engine support in OpenSSL 3 is deprecated."}],"signature":{"parameters":[{"name":"engine","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"flags","type":{"text":"crypto.constants","links":[{"name":"crypto.constants","href":"crypto.html#cryptoconstants","start":0,"end":16}]},"description":"","default":"crypto.constants.ENGINE_METHOD_ALL","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Load and set the `engine` for some or all OpenSSL functions (selected by flags).\nSupport for custom engines in OpenSSL is deprecated from OpenSSL 3.\n\n`engine` could be either an id or a path to the engine's shared library.\n\nThe optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`\nis a bit field taking one of or a mix of the following flags (defined in\n`crypto.constants`):\n\n* `crypto.constants.ENGINE_METHOD_RSA`\n* `crypto.constants.ENGINE_METHOD_DSA`\n* `crypto.constants.ENGINE_METHOD_DH`\n* `crypto.constants.ENGINE_METHOD_RAND`\n* `crypto.constants.ENGINE_METHOD_EC`\n* `crypto.constants.ENGINE_METHOD_CIPHERS`\n* `crypto.constants.ENGINE_METHOD_DIGESTS`\n* `crypto.constants.ENGINE_METHOD_PKEY_METHS`\n* `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`\n* `crypto.constants.ENGINE_METHOD_ALL`\n* `crypto.constants.ENGINE_METHOD_NONE`","summary":"Load and set the `engine` for some or all OpenSSL functions (selected by flags). Support for custom engines in OpenSSL is deprecated from OpenSSL 3.","examples":[],"children":[]},{"kind":"method","id":"cryptosetfipsbool","name":"setFips","title":"`crypto.setFips(bool)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"bool","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` to enable FIPS mode, `false` to disable it.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Changes [FIPS mode](#fips-mode). With OpenSSL 3, this only adds or removes `fips=yes` in\nthe default property query. It does not install, load, initialize, or validate\na FIPS provider. For a usable FIPS configuration, install the provider and\nconfigure OpenSSL to load it when Node.js starts, as described in [FIPS\nmode](#fips-mode).\n\nIf no loaded provider supplies a requested cryptographic implementation\nmatching `fips=yes`, the call can still succeed and `crypto.getFips()` can still\nreturn `1`, but fetching that implementation fails. Affected `node:crypto`\noperations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do\nnot require a new fetch, including those using previously fetched\nimplementations or initialized operation contexts, may still succeed. Call this\nmethod during application initialization, before application code uses other\nOpenSSL-backed APIs.\n\nThis method only affects subsequent algorithm fetches. Node.js initializes some\nOpenSSL state before application code runs. When the property query must be\nactive from process startup, set `default_properties = fips=yes` in the OpenSSL\nconfiguration or use [`--enable-fips`](cli.html#--enable-fips) or [`--force-fips`](cli.html#--force-fips). The command-line\nflags additionally require a configured provider named `fips` to initialize and\npass its self-test; Node.js fails to start otherwise.\n\nThrows an error if OpenSSL cannot change the state. FIPS mode cannot be\ndisabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,\nenabling FIPS mode requires a FIPS-capable OpenSSL build.","summary":"Changes FIPS mode. With OpenSSL 3, this only adds or removes `fips=yes` in the default property query. It does not install, load, initialize, or validate a FIPS provider. For a usable FIPS configuration, install the provider and configure OpenSSL to load it when Node.js starts, as described in FIPS mode.","examples":[],"children":[]},{"kind":"method","id":"cryptosignalgorithm-data-key-callback","name":"sign","title":"`crypto.sign(algorithm, data, key[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62474","commit":null,"description":"Add support for Ed25519 context parameter."},{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59570","commit":null,"description":"Add support for ML-DSA, Ed448, and SLH-DSA context parameter."},{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59537","commit":null,"description":"Add support for SLH-DSA signing."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA signing."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v15.12.0"],"prUrl":"https://github.com/nodejs/node/pull/37500","commit":null,"description":"Optional callback argument added."},{"versions":["v13.2.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/29292","commit":null,"description":"This function now supports IEEE-P1363 DSA and ECDSA signatures."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string | null | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":16,"end":25}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"ArrayBuffer | Buffer | SharedArrayBuffer | TypedArray | DataView | string","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":23,"end":40},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":43,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey | URL","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86},{"name":"URL","href":"url.html#the-whatwg-url-api","start":89,"end":92}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signature","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"if the `callback` function is not provided."}},"description":"Calculates and returns the signature for `data` using the given private key and\nalgorithm. If `algorithm` is `null` or `undefined`, then the algorithm is\ndependent upon the key type.\n\n`algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and\nML-DSA.\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if `key` had been\npassed to [`crypto.createPrivateKey()`](#cryptocreateprivatekeykey). When `key` is a string, `ArrayBuffer`,\n[`Buffer`](buffer.html), `TypedArray`, or `DataView`, it must contain PEM-encoded key\nmaterial. If it is an object, the following additional properties can be\npassed:\n\n* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the\n  format of the generated signature. It can be one of the following:\n  * `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.\n  * `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.\n* `padding` {integer} Optional padding value for RSA, one of the following:\n\n  * `crypto.constants.RSA_PKCS1_PADDING` (default)\n  * `crypto.constants.RSA_PKCS1_PSS_PADDING`\n\n  `RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function\n  used to sign the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt).\n* `saltLength` {integer} Salt length for when padding is\n  `RSA_PKCS1_PSS_PADDING`. The special value\n  `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest\n  size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the\n  maximum permissible value.\n* `context` {ArrayBuffer | Buffer | TypedArray | DataView} For Ed25519[^openssl32]\n  (using Ed25519ctx from [RFC 8032](https://www.rfc-editor.org/rfc/rfc8032.txt)), Ed448, ML-DSA, and SLH-DSA,\n  this option specifies the optional context to differentiate signatures\n  generated for different purposes with the same key.\n\nIf the `callback` function is provided this function uses libuv's threadpool.","summary":"Calculates and returns the signature for `data` using the given private key and algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the key type.","examples":[],"children":[]},{"kind":"property","id":"cryptosubtle","name":"subtle","title":"`crypto.subtle`","scope":"module","overloadOf":null,"stability":null,"added":["v17.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"SubtleCrypto","links":[{"name":"SubtleCrypto","href":"webcrypto.html#class-subtlecrypto","start":0,"end":12}]},"default":null,"description":"A convenient alias for [`crypto.webcrypto.subtle`](webcrypto.html#class-subtlecrypto).","summary":"A convenient alias for `crypto.webcrypto.subtle`.","examples":[],"children":[]},{"kind":"method","id":"cryptotimingsafeequala-b","name":"timingSafeEqual","title":"`crypto.timingSafeEqual(a, b)`","scope":"module","overloadOf":null,"stability":null,"added":["v6.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The a and b arguments can also be ArrayBuffer."}],"signature":{"parameters":[{"name":"a","type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"b","type":{"text":"ArrayBuffer | Buffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":36,"end":44}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"This function compares the underlying bytes that represent the given\n`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time\nalgorithm.\n\nThis function does not leak timing information that\nwould allow an attacker to guess one of the values. This is suitable for\ncomparing HMAC digests or secret values like authentication cookies or\n[capability urls](https://www.w3.org/TR/capability-urls/).\n\n`a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they\nmust have the same byte length. An error is thrown if `a` and `b` have\ndifferent byte lengths.\n\nIf at least one of `a` and `b` is a `TypedArray` with more than one byte per\nentry, such as `Uint16Array`, the result will be computed using the platform\nbyte order.\n\n<strong class=\"critical\">When both of the inputs are `Float32Array`s or\n`Float64Array`s, this function might return unexpected results due to IEEE 754\nencoding of floating-point numbers. In particular, neither `x === y` nor\n`Object.is(x, y)` implies that the byte representations of two floating-point\nnumbers `x` and `y` are equal.</strong>\n\nUse of `crypto.timingSafeEqual` does not guarantee that the *surrounding* code\nis timing-safe. Care should be taken to ensure that the surrounding code does\nnot introduce timing vulnerabilities.","summary":"This function compares the underlying bytes that represent the given `ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time algorithm.","examples":[],"children":[]},{"kind":"method","id":"cryptoverifyalgorithm-data-key-signature-callback","name":"verify","title":"`crypto.verify(algorithm, data, key, signature[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.0.0"],"prUrl":"https://github.com/nodejs/node/pull/62474","commit":null,"description":"Add support for Ed25519 context parameter."},{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59570","commit":null,"description":"Add support for ML-DSA, Ed448, and SLH-DSA context parameter."},{"versions":["v24.8.0"],"prUrl":"https://github.com/nodejs/node/pull/59537","commit":null,"description":"Add support for SLH-DSA signature verification."},{"versions":["v24.6.0"],"prUrl":"https://github.com/nodejs/node/pull/59259","commit":null,"description":"Add support for ML-DSA signature verification."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v15.12.0"],"prUrl":"https://github.com/nodejs/node/pull/37500","commit":null,"description":"Optional callback argument added."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35093","commit":null,"description":"The data, key, and signature arguments can also be ArrayBuffer."},{"versions":["v13.2.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/29292","commit":null,"description":"This function now supports IEEE-P1363 DSA and ECDSA signatures."}],"signature":{"parameters":[{"name":"algorithm","type":{"text":"string | null | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":16,"end":25}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"ArrayBuffer | Buffer | SharedArrayBuffer | TypedArray | DataView | string","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":23,"end":40},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":43,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":67,"end":73}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"key","type":{"text":"Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKey","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":18,"end":29},{"name":"Buffer","href":"buffer.html#class-buffer","start":32,"end":38},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":41,"end":51},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":54,"end":62},{"name":"KeyObject","href":"crypto.html#class-keyobject","start":65,"end":74},{"name":"CryptoKey","href":"webcrypto.html#class-cryptokey","start":77,"end":86}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signature","type":{"text":"ArrayBuffer | Buffer | SharedArrayBuffer | TypedArray | DataView","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"Buffer","href":"buffer.html#class-buffer","start":14,"end":20},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":23,"end":40},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":43,"end":53},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":56,"end":64}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"result","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` or `false` depending on the validity of the\nsignature for the data and public key if the `callback` function is not\nprovided."}},"description":"Verifies the given signature for `data` using the given key and algorithm. If\n`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the\nkey type.\n\n`algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and\nML-DSA.\n\nIf `key` is not a [`KeyObject`](#class-keyobject), this function behaves as if `key` had been\npassed to [`crypto.createPublicKey()`](#cryptocreatepublickeykey). When `key` is a string, `ArrayBuffer`,\n[`Buffer`](buffer.html), `TypedArray`, or `DataView`, it must contain PEM-encoded key\nmaterial. If it is an object, the following additional properties can be\npassed:\n\n* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the\n  format of the signature. It can be one of the following:\n  * `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.\n  * `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.\n* `padding` {integer} Optional padding value for RSA, one of the following:\n\n  * `crypto.constants.RSA_PKCS1_PADDING` (default)\n  * `crypto.constants.RSA_PKCS1_PSS_PADDING`\n\n  `RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function\n  used to sign the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt).\n* `saltLength` {integer} Salt length for when padding is\n  `RSA_PKCS1_PSS_PADDING`. The special value\n  `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest\n  size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the\n  maximum permissible value.\n* `context` {ArrayBuffer | Buffer | TypedArray | DataView} For Ed25519[^openssl32]\n  (using Ed25519ctx from [RFC 8032](https://www.rfc-editor.org/rfc/rfc8032.txt)), Ed448, ML-DSA, and SLH-DSA,\n  this option specifies the optional context to differentiate signatures\n  generated for different purposes with the same key.\n\nThe `signature` argument is the previously calculated signature for the `data`.\n\nBecause public keys can be derived from private keys, a private key or a public\nkey may be passed for `key`.\n\nIf the `callback` function is provided this function uses libuv's threadpool.","summary":"Verifies the given signature for `data` using the given key and algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the key type.","examples":[],"children":[]},{"kind":"property","id":"cryptowebcrypto","name":"webcrypto","title":"`crypto.webcrypto`","scope":"module","overloadOf":null,"stability":null,"added":["v15.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"Type: {Crypto} An implementation of the Web Crypto API standard.\n\nSee the [Web Crypto API documentation](webcrypto.html) for details.","summary":"Type: {Crypto} An implementation of the Web Crypto API standard.","examples":[],"children":[]}]},{"kind":"section","id":"notes","name":"Notes","title":"Notes","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"section","id":"using-strings-as-inputs-to-cryptographic-apis","name":"Using strings as inputs to cryptographic APIs","title":"Using strings as inputs to cryptographic APIs","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"For historical reasons, many cryptographic APIs provided by Node.js accept\nstrings as inputs where the underlying cryptographic algorithm works on byte\nsequences. These instances include plaintexts, ciphertexts, symmetric keys,\ninitialization vectors, passphrases, salts, authentication tags,\nand additional authenticated data.\n\nWhen passing strings to cryptographic APIs, consider the following factors.\n\n* Not all byte sequences are valid UTF-8 strings. Therefore, when a byte\n  sequence of length `n` is derived from a string, its entropy is generally\n  lower than the entropy of a random or pseudorandom `n` byte sequence.\n  For example, no UTF-8 string will result in the byte sequence `c0 af`. Secret\n  keys should almost exclusively be random or pseudorandom byte sequences.\n* Similarly, when converting random or pseudorandom byte sequences to UTF-8\n  strings, subsequences that do not represent valid code points may be replaced\n  by the Unicode replacement character (`U+FFFD`). The byte representation of\n  the resulting Unicode string may, therefore, not be equal to the byte sequence\n  that the string was created from.\n\n  ```js\n  const original = [0xc0, 0xaf];\n  const bytesAsString = Buffer.from(original).toString('utf8');\n  const stringAsBytes = Buffer.from(bytesAsString, 'utf8');\n  console.log(stringAsBytes);\n  // Prints '<Buffer ef bf bd ef bf bd>'.\n  ```\n\n  The outputs of ciphers, hash functions, signature algorithms, and key\n  derivation functions are pseudorandom byte sequences and should not be\n  used as Unicode strings.\n* When strings are obtained from user input, some Unicode characters can be\n  represented in multiple equivalent ways that result in different byte\n  sequences. For example, when passing a user passphrase to a key derivation\n  function, such as PBKDF2 or scrypt, the result of the key derivation function\n  depends on whether the string uses composed or decomposed characters. Node.js\n  does not normalize character representations. Developers should consider using\n  [`String.prototype.normalize()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on user inputs before passing them to\n  cryptographic APIs.","summary":"For historical reasons, many cryptographic APIs provided by Node.js accept strings as inputs where the underlying cryptographic algorithm works on byte sequences. These instances include plaintexts, ciphertexts, symmetric keys, initialization vectors, passphrases, salts, authentication tags, and additional authenticated data.","examples":[{"language":"js","displayName":null,"code":"const original = [0xc0, 0xaf];\nconst bytesAsString = Buffer.from(original).toString('utf8');\nconst stringAsBytes = Buffer.from(bytesAsString, 'utf8');\nconsole.log(stringAsBytes);\n// Prints '<Buffer ef bf bd ef bf bd>'."}],"children":[]},{"kind":"section","id":"legacy-streams-api-prior-to-nodejs-010","name":"Legacy streams API (prior to Node.js 0.10)","title":"Legacy streams API (prior to Node.js 0.10)","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The Crypto module was added to Node.js before there was the concept of a\nunified Stream API, and before there were [`Buffer`](buffer.html) objects for handling\nbinary data. As such, many `crypto` classes have methods not\ntypically found on other Node.js classes that implement the [streams](stream.html)\nAPI (e.g. `update()`, `final()`, or `digest()`). Also, many methods accepted\nand returned `'latin1'` encoded strings by default rather than `Buffer`s. This\ndefault was changed in Node.js 0.9.3 to use [`Buffer`](buffer.html) objects by default\ninstead.","summary":"The Crypto module was added to Node.js before there was the concept of a unified Stream API, and before there were `Buffer` objects for handling binary data. As such, many `crypto` classes have methods not typically found on other Node.js classes that implement the streams API (e.g. `update()`, `final()`, or `digest()`). Also, many methods accepted and returned `'latin1'` encoded strings by default rather than `Buffer`s. This default was changed in Node.js 0.9.3 to use `Buffer` objects by default instead.","examples":[],"children":[]},{"kind":"section","id":"support-for-weak-or-compromised-algorithms","name":"Support for weak or compromised algorithms","title":"Support for weak or compromised algorithms","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:crypto` module still supports some algorithms which are already\ncompromised and are not recommended for use. The API also allows\nthe use of ciphers and hashes with a small key size that are too weak for safe\nuse.\n\nUsers should take full responsibility for selecting the crypto\nalgorithm and key size according to their security requirements.\n\nBased on the recommendations of [NIST SP 800-131A](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf):\n\n* MD5 and SHA-1 are no longer acceptable where collision resistance is\n  required such as digital signatures.\n* The key used with RSA, DSA, and DH algorithms is recommended to have\n  at least 2048 bits and that of the curve of ECDSA and ECDH at least\n  224 bits, to be safe to use for several years.\n* The DH groups of `modp1`, `modp2` and `modp5` have a key size\n  smaller than 2048 bits and are not recommended.\n\nSee the reference for other recommendations and details.\n\nSome algorithms that have known weaknesses and are of little relevance in\npractice are only available through the [legacy provider](cli.html#--openssl-legacy-provider), which is not\nenabled by default.","summary":"The `node:crypto` module still supports some algorithms which are already compromised and are not recommended for use. The API also allows the use of ciphers and hashes with a small key size that are too weak for safe use.","examples":[],"children":[]},{"kind":"section","id":"ccm-mode","name":"CCM mode","title":"CCM mode","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"CCM is one of the supported [AEAD algorithms](https://en.wikipedia.org/wiki/Authenticated_encryption). Applications which use this\nmode must adhere to certain restrictions when using the cipher API:\n\n* The authentication tag length must be specified during cipher creation by\n  setting the `authTagLength` option and must be one of 4, 6, 8, 10, 12, 14 or\n  16 bytes.\n* The length of the initialization vector (nonce) `N` must be between 7 and 13\n  bytes (`7 ≤ N ≤ 13`).\n* The length of the plaintext is limited to `2 ** (8 * (15 - N))` bytes.\n* When decrypting, the authentication tag must be set via `setAuthTag()` before\n  calling `update()`.\n  Otherwise, decryption will fail and `final()` will throw an error in\n  compliance with section 2.6 of [RFC 3610](https://www.rfc-editor.org/rfc/rfc3610.txt).\n* Using stream methods such as `write(data)`, `end(data)` or `pipe()` in CCM\n  mode might fail as CCM cannot handle more than one chunk of data per instance.\n* When passing additional authenticated data (AAD), the length of the actual\n  message in bytes must be passed to `setAAD()` via the `plaintextLength`\n  option.\n  Many crypto libraries include the authentication tag in the ciphertext,\n  which means that they produce ciphertexts of the length\n  `plaintextLength + authTagLength`. Node.js does not include the authentication\n  tag, so the ciphertext length is always `plaintextLength`.\n  This is not necessary if no AAD is used.\n* As CCM processes the whole message at once, `update()` must be called exactly\n  once.\n* Even though calling `update()` is sufficient to encrypt/decrypt the message,\n  applications *must* call `final()` to compute or verify the\n  authentication tag.\n\n```mjs\nimport { Buffer } from 'node:buffer';\nconst {\n  createCipheriv,\n  createDecipheriv,\n  randomBytes,\n} = await import('node:crypto');\n\nconst key = 'keykeykeykeykeykeykeykey';\nconst nonce = randomBytes(12);\n\nconst aad = Buffer.from('0123456789', 'hex');\n\nconst cipher = createCipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\nconst plaintext = 'Hello world';\ncipher.setAAD(aad, {\n  plaintextLength: Buffer.byteLength(plaintext),\n});\nconst ciphertext = cipher.update(plaintext, 'utf8');\ncipher.final();\nconst tag = cipher.getAuthTag();\n\n// Now transmit { ciphertext, nonce, tag }.\n\nconst decipher = createDecipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\ndecipher.setAuthTag(tag);\ndecipher.setAAD(aad, {\n  plaintextLength: ciphertext.length,\n});\nconst receivedPlaintext = decipher.update(ciphertext, null, 'utf8');\n\ntry {\n  decipher.final();\n} catch (err) {\n  throw new Error('Authentication failed!', { cause: err });\n}\n\nconsole.log(receivedPlaintext);\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\nconst {\n  createCipheriv,\n  createDecipheriv,\n  randomBytes,\n} = require('node:crypto');\n\nconst key = 'keykeykeykeykeykeykeykey';\nconst nonce = randomBytes(12);\n\nconst aad = Buffer.from('0123456789', 'hex');\n\nconst cipher = createCipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\nconst plaintext = 'Hello world';\ncipher.setAAD(aad, {\n  plaintextLength: Buffer.byteLength(plaintext),\n});\nconst ciphertext = cipher.update(plaintext, 'utf8');\ncipher.final();\nconst tag = cipher.getAuthTag();\n\n// Now transmit { ciphertext, nonce, tag }.\n\nconst decipher = createDecipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\ndecipher.setAuthTag(tag);\ndecipher.setAAD(aad, {\n  plaintextLength: ciphertext.length,\n});\nconst receivedPlaintext = decipher.update(ciphertext, null, 'utf8');\n\ntry {\n  decipher.final();\n} catch (err) {\n  throw new Error('Authentication failed!', { cause: err });\n}\n\nconsole.log(receivedPlaintext);\n```","summary":"CCM is one of the supported AEAD algorithms. Applications which use this mode must adhere to certain restrictions when using the cipher API:","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nconst {\n  createCipheriv,\n  createDecipheriv,\n  randomBytes,\n} = await import('node:crypto');\n\nconst key = 'keykeykeykeykeykeykeykey';\nconst nonce = randomBytes(12);\n\nconst aad = Buffer.from('0123456789', 'hex');\n\nconst cipher = createCipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\nconst plaintext = 'Hello world';\ncipher.setAAD(aad, {\n  plaintextLength: Buffer.byteLength(plaintext),\n});\nconst ciphertext = cipher.update(plaintext, 'utf8');\ncipher.final();\nconst tag = cipher.getAuthTag();\n\n// Now transmit { ciphertext, nonce, tag }.\n\nconst decipher = createDecipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\ndecipher.setAuthTag(tag);\ndecipher.setAAD(aad, {\n  plaintextLength: ciphertext.length,\n});\nconst receivedPlaintext = decipher.update(ciphertext, null, 'utf8');\n\ntry {\n  decipher.final();\n} catch (err) {\n  throw new Error('Authentication failed!', { cause: err });\n}\n\nconsole.log(receivedPlaintext);"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\nconst {\n  createCipheriv,\n  createDecipheriv,\n  randomBytes,\n} = require('node:crypto');\n\nconst key = 'keykeykeykeykeykeykeykey';\nconst nonce = randomBytes(12);\n\nconst aad = Buffer.from('0123456789', 'hex');\n\nconst cipher = createCipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\nconst plaintext = 'Hello world';\ncipher.setAAD(aad, {\n  plaintextLength: Buffer.byteLength(plaintext),\n});\nconst ciphertext = cipher.update(plaintext, 'utf8');\ncipher.final();\nconst tag = cipher.getAuthTag();\n\n// Now transmit { ciphertext, nonce, tag }.\n\nconst decipher = createDecipheriv('aes-192-ccm', key, nonce, {\n  authTagLength: 16,\n});\ndecipher.setAuthTag(tag);\ndecipher.setAAD(aad, {\n  plaintextLength: ciphertext.length,\n});\nconst receivedPlaintext = decipher.update(ciphertext, null, 'utf8');\n\ntry {\n  decipher.final();\n} catch (err) {\n  throw new Error('Authentication failed!', { cause: err });\n}\n\nconsole.log(receivedPlaintext);"}],"children":[]},{"kind":"section","id":"siv-and-gcm-siv-modes","name":"SIV and GCM-SIV modes","title":"SIV and GCM-SIV modes","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`SIV`[^openssl30] and `GCM-SIV`[^openssl32] are supported [AEAD algorithms](https://en.wikipedia.org/wiki/Authenticated_encryption)\nwhen supported by OpenSSL. Applications which use these modes must adhere to\ncertain restrictions when using the cipher API:\n\n* The authentication tag length is fixed at 16 bytes.\n* `AES-SIV` keys are twice the named AES key size: `aes-128-siv` requires a\n  32-byte key, `aes-192-siv` requires a 48-byte key, and `aes-256-siv`\n  requires a 64-byte key.\n* `AES-SIV` ciphers do not use an initialization vector. Pass `null` or a\n  zero-length `iv` to [`crypto.createCipheriv()`](#cryptocreatecipherivalgorithm-key-iv-options) or\n  [`crypto.createDecipheriv()`](#cryptocreatedecipherivalgorithm-key-iv-options).\n* `AES-SIV` and `AES-GCM-SIV` support zero-length plaintext only with OpenSSL\n  3.5 or later.\n* `AES-SIV` does not have a separate nonce or IV parameter. RFC 5297 defines\n  `AES-SIV` over an ordered list of associated-data inputs. Each `setAAD()`\n  call supplies one input in that list. If a protocol uses a nonce with\n  `AES-SIV`, call `setAAD(nonce)` after the other associated-data inputs and\n  before `update()`. At most 126 associated-data inputs may be supplied.\n* `AES-GCM-SIV` ciphers require a 12-byte initialization vector.\n* When decrypting, the authentication tag must be set via `setAuthTag()` before\n  calling `update()`.\n* Using stream methods such as `write(data)`, `end(data)` or `pipe()` might\n  fail as these modes cannot handle more than one chunk of data per instance.\n* As these modes process the whole message at once, `update()` must be called\n  exactly once.\n* Even though calling `update()` is sufficient to encrypt/decrypt the message,\n  applications *must* call `final()` to compute or verify the authentication\n  tag.","summary":"`SIV` and `GCM-SIV` are supported AEAD algorithms when supported by OpenSSL. Applications which use these modes must adhere to certain restrictions when using the cipher API:","examples":[],"children":[]},{"kind":"section","id":"fips-mode","name":"FIPS mode","title":"FIPS mode","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js\nis not itself FIPS validated. Validation belongs to a specific OpenSSL module or\nprovider and only applies when it is deployed according to its security policy.\nVendor-provided Node.js or OpenSSL builds can require a different configuration;\nfollow the vendor's documentation for those builds.\n\nWith OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.\n\nWith OpenSSL 3, FIPS support uses the provider model described in the\n[OpenSSL FIPS module guide](https://docs.openssl.org/master/man7/fips_module/). Using FIPS-approved implementations requires:\n\n* A correctly installed OpenSSL 3 FIPS provider.\n* An OpenSSL 3 [FIPS module configuration file](https://docs.openssl.org/3.0/man5/fips_config/).\n* The FIPS provider to be loaded into the OpenSSL library context used by\n  Node.js, normally by activating it in an OpenSSL configuration file when\n  Node.js starts.\n* The default property query to include `fips=yes` when cryptographic\n  implementations are fetched. This can be set from process startup by the\n  OpenSSL configuration, [`--enable-fips`](cli.html#--enable-fips), or [`--force-fips`](cli.html#--force-fips), or for\n  subsequent fetches by `crypto.setFips(true)`.\n\nAn example OpenSSL 3 configuration file looks like this:\n\n```text\nnodejs_conf = nodejs_init\nconfig_diagnostics = 1\n\n.include /<absolute path>/fipsmodule.cnf\n\n[nodejs_init]\nproviders = provider_sect\nalg_section = algorithm_sect\n\n[provider_sect]\n# The fips section name should match the section name inside the\n# included fipsmodule.cnf.\nfips = fips_sect\nbase = base_sect\n\n[base_sect]\nactivate = 1\n\n[algorithm_sect]\ndefault_properties = fips=yes\n```\n\nThe `fipsmodule.cnf` file is generated as part of the FIPS provider installation\nand contains module integrity and self-test information. The exact command and\narguments are installation-specific; see [OpenSSL FIPS configuration](https://docs.openssl.org/3.0/man5/fips_config/) and the\n[OpenSSL FIPS module guide](https://docs.openssl.org/master/man7/fips_module/). The installation uses `openssl fipsinstall`.\n\nThe example activates the provider and enables the `fips=yes` property query\nwhen Node.js starts. To activate the provider at startup but enable the property\nquery later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and\nthe `[algorithm_sect]` block. The provider must still be loaded; when using this\nstartup configuration, keep its activation enabled. `crypto.setFips(true)`\nshould be called before application code uses other OpenSSL-backed APIs. It is\nnot equivalent to enabling the property query from process startup because\nNode.js initializes some OpenSSL state before application code runs. Use the\nexample as written, [`--enable-fips`](cli.html#--enable-fips), or [`--force-fips`](cli.html#--force-fips) when the property\nquery must be active from process startup.\n\n`config_diagnostics` causes configuration errors to prevent startup instead of\nbeing ignored. The `base` provider supplies non-cryptographic supporting\nalgorithms, such as encoders and decoders, that are commonly needed alongside\nthe FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default\nalgorithm selection to implementations that match `fips=yes`.\n\nSet `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded\nprovider, `OPENSSL_MODULES` can set the directory containing the provider module.\nFor example:\n\n```bash\nexport OPENSSL_CONF=/<path to configuration file>/nodejs.cnf\nexport OPENSSL_MODULES=/<path to openssl lib>/ossl-modules\n```\n\nThe [`--openssl-config`](cli.html#--openssl-configfile) command-line option selects the configuration file and\ntakes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default\nconfiguration file is used.\n\nBy default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual\n`openssl_conf` section. Use [`--openssl-shared-config`](cli.html#--openssl-shared-config) to read `openssl_conf`,\nor build Node.js with `./configure --openssl-conf-name=<name>` to change the\ndefault section name.\n\nOn OpenSSL 3, the configuration above enables the `fips=yes` property query at\nstartup. The following controls are also available:\n\n* [`--enable-fips`](cli.html#--enable-fips) and [`--force-fips`](cli.html#--force-fips) enable the property query and\n  additionally require the configured provider named `fips` to initialize and\n  pass its self-test. Node.js exits if that check fails. `--force-fips` also\n  prevents FIPS mode from being disabled from script code.\n* [`crypto.setFips()`](#cryptosetfipsbool) changes the FIPS/property-query state. On OpenSSL 3, it\n  does not install, load, initialize, or validate a provider. Implementations\n  fetched before the call are not changed.\n* [`crypto.getFips()`](#cryptogetfips) reports the FIPS/property-query state. On OpenSSL 3, a\n  return value of `1` does not prove that a FIPS provider is loaded or validated.\n\nWith OpenSSL 1.1.1, these controls use the library's FIPS mode support and\nrequire a FIPS-capable OpenSSL build.\n\nOnly algorithms available under the active FIPS settings can be used. With\nOpenSSL 3, if no loaded provider supplies a requested cryptographic\nimplementation matching `fips=yes`, fetching it fails, typically with\n`ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that\nNode.js supports when FIPS mode is disabled but that are unavailable under the\nactive FIPS settings.\n\nOpenSSL documents that the same FIPS provider cannot be used by multiple copies\nof `libcrypto` in one process. This can affect native addons that load another\ncopy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy\nof the provider for each `libcrypto` instance. See [OpenSSL FIPS provider\nlimitations](https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/).","summary":"Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js is not itself FIPS validated. Validation belongs to a specific OpenSSL module or provider and only applies when it is deployed according to its security policy. Vendor-provided Node.js or OpenSSL builds can require a different configuration; follow the vendor's documentation for those builds.","examples":[{"language":"text","displayName":null,"code":"nodejs_conf = nodejs_init\nconfig_diagnostics = 1\n\n.include /<absolute path>/fipsmodule.cnf\n\n[nodejs_init]\nproviders = provider_sect\nalg_section = algorithm_sect\n\n[provider_sect]\n# The fips section name should match the section name inside the\n# included fipsmodule.cnf.\nfips = fips_sect\nbase = base_sect\n\n[base_sect]\nactivate = 1\n\n[algorithm_sect]\ndefault_properties = fips=yes"},{"language":"bash","displayName":null,"code":"export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf\nexport OPENSSL_MODULES=/<path to openssl lib>/ossl-modules"}],"children":[]}]},{"kind":"section","id":"crypto-constants","name":"Crypto constants","title":"Crypto constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants exported by `crypto.constants` apply to various uses of\nthe `node:crypto`, `node:tls`, and `node:https` modules and are generally\nspecific to OpenSSL.","summary":"The following constants exported by `crypto.constants` apply to various uses of the `node:crypto`, `node:tls`, and `node:https` modules and are generally specific to OpenSSL.","examples":[],"children":[{"kind":"section","id":"openssl-options","name":"OpenSSL options","title":"OpenSSL options","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"See the [list of SSL OP Flags](https://wiki.openssl.org/index.php/List_of_SSL_OP_Flags#Table_of_Options) for details.\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_ALL</code></td>\n    <td>Applies multiple bug workarounds within OpenSSL. See\n    <a href=\"https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html\">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>\n    for detail.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_ALLOW_NO_DHE_KEX</code></td>\n    <td>Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode\n    for TLS v1.3</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION</code></td>\n    <td>Allows legacy insecure renegotiation between OpenSSL and unpatched\n    clients or servers. See\n    <a href=\"https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html\">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_CIPHER_SERVER_PREFERENCE</code></td>\n    <td>Attempts to use the server's preferences instead of the client's when\n    selecting a cipher. Behavior depends on protocol version. See\n    <a href=\"https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html\">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_CISCO_ANYCONNECT</code></td>\n    <td>Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_COOKIE_EXCHANGE</code></td>\n    <td>Instructs OpenSSL to turn on cookie exchange.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_CRYPTOPRO_TLSEXT_BUG</code></td>\n    <td>Instructs OpenSSL to add server-hello extension from an early version\n    of the cryptopro draft.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS</code></td>\n    <td>Instructs OpenSSL to disable an SSL 3.0/TLS 1.0 vulnerability\n    workaround added in OpenSSL 0.9.6d.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_LEGACY_SERVER_CONNECT</code></td>\n    <td>Allows initial connection to servers that do not support RI.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_COMPRESSION</code></td>\n    <td>Instructs OpenSSL to disable support for SSL/TLS compression.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_ENCRYPT_THEN_MAC</code></td>\n    <td>Instructs OpenSSL to disable encrypt-then-MAC.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_QUERY_MTU</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_RENEGOTIATION</code></td>\n    <td>Instructs OpenSSL to disable renegotiation.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION</code></td>\n    <td>Instructs OpenSSL to always start a new session when performing\n    renegotiation.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_SSLv2</code></td>\n    <td>Instructs OpenSSL to turn off SSL v2</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_SSLv3</code></td>\n    <td>Instructs OpenSSL to turn off SSL v3</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_TICKET</code></td>\n    <td>Instructs OpenSSL to disable use of RFC4507bis tickets.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_TLSv1</code></td>\n    <td>Instructs OpenSSL to turn off TLS v1</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_TLSv1_1</code></td>\n    <td>Instructs OpenSSL to turn off TLS v1.1</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_TLSv1_2</code></td>\n    <td>Instructs OpenSSL to turn off TLS v1.2</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_NO_TLSv1_3</code></td>\n    <td>Instructs OpenSSL to turn off TLS v1.3</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_PRIORITIZE_CHACHA</code></td>\n    <td>Instructs OpenSSL server to prioritize ChaCha20-Poly1305\n    when the client does.\n    This option has no effect if\n    <code>SSL_OP_CIPHER_SERVER_PREFERENCE</code>\n    is not enabled.</td>\n  </tr>\n  <tr>\n    <td><code>SSL_OP_TLS_ROLLBACK_BUG</code></td>\n    <td>Instructs OpenSSL to disable version rollback attack detection.</td>\n  </tr>\n</table>","summary":"See the list of SSL OP Flags for details.","examples":[],"children":[]},{"kind":"section","id":"openssl-engine-constants","name":"OpenSSL engine constants","title":"OpenSSL engine constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_RSA</code></td>\n    <td>Limit engine usage to RSA</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_DSA</code></td>\n    <td>Limit engine usage to DSA</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_DH</code></td>\n    <td>Limit engine usage to DH</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_RAND</code></td>\n    <td>Limit engine usage to RAND</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_EC</code></td>\n    <td>Limit engine usage to EC</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_CIPHERS</code></td>\n    <td>Limit engine usage to CIPHERS</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_DIGESTS</code></td>\n    <td>Limit engine usage to DIGESTS</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_PKEY_METHS</code></td>\n    <td>Limit engine usage to PKEY_METHS</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_PKEY_ASN1_METHS</code></td>\n    <td>Limit engine usage to PKEY_ASN1_METHS</td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_ALL</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>ENGINE_METHOD_NONE</code></td>\n    <td></td>\n  </tr>\n</table>","summary":"","examples":[],"children":[]},{"kind":"section","id":"other-openssl-constants","name":"Other OpenSSL constants","title":"Other OpenSSL constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>DH_CHECK_P_NOT_SAFE_PRIME</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>DH_CHECK_P_NOT_PRIME</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>DH_UNABLE_TO_CHECK_GENERATOR</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>DH_NOT_SUITABLE_GENERATOR</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_PKCS1_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_SSLV23_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_NO_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_PKCS1_OAEP_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_X931_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_PKCS1_PSS_PADDING</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>RSA_PSS_SALTLEN_DIGEST</code></td>\n    <td>Sets the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to the\n        digest size when signing or verifying.</td>\n  </tr>\n  <tr>\n    <td><code>RSA_PSS_SALTLEN_MAX_SIGN</code></td>\n    <td>Sets the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to the\n        maximum permissible value when signing data.</td>\n  </tr>\n  <tr>\n    <td><code>RSA_PSS_SALTLEN_AUTO</code></td>\n    <td>Causes the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to be\n        determined automatically when verifying a signature.</td>\n  </tr>\n  <tr>\n    <td><code>POINT_CONVERSION_COMPRESSED</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>POINT_CONVERSION_UNCOMPRESSED</code></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td><code>POINT_CONVERSION_HYBRID</code></td>\n    <td></td>\n  </tr>\n</table>","summary":"","examples":[],"children":[]},{"kind":"section","id":"nodejs-crypto-constants","name":"Node.js crypto constants","title":"Node.js crypto constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>defaultCoreCipherList</code></td>\n    <td>Specifies the built-in default cipher list used by Node.js.</td>\n  </tr>\n  <tr>\n    <td><code>defaultCipherList</code></td>\n    <td>Specifies the active default cipher list used by the current Node.js\n    process.</td>\n  </tr>\n</table>\n\n[^openssl30]: Requires OpenSSL >= 3.0\n\n[^openssl32]: Requires OpenSSL >= 3.2\n\n[^openssl35]: Requires OpenSSL >= 3.5","summary":"","examples":[],"children":[]}]}]}