chunk_id large_stringlengths 36 36 | doc_type large_stringclasses 2
values | category large_stringclasses 17
values | document large_stringclasses 50
values | version_raw large_stringclasses 590
values | chunk_index int64 0 262 | text large_stringlengths 11 5.69k | file_path large_stringclasses 882
values |
|---|---|---|---|---|---|---|---|
ed3de4e6-c11a-58e4-a7e8-37333adbf543 | docs | nodejs | nodejs_crypto | 10x | 137 | returned as a [`Buffer`](buffer.html).
An exception is thrown when any of the input arguments specify invalid values
or types.
```None
const crypto = require('crypto');
// Using the factory defaults.
const key1 = crypto.scryptSync('secret', 'salt', 64);
console.log(key1.toString('hex')); // '3745e48...08d59ae'
// Us... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
e6668b56-09c7-5948-b82a-24c05105fab7 | docs | nodejs | nodejs_crypto | 10x | 138 | The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`
is a bit field taking one of or a mix of the following flags (defined in
`crypto.constants`):
* `crypto.constants.ENGINE_METHOD_RSA`
* `crypto.constants.ENGINE_METHOD_DSA`
* `crypto.constants.ENGINE_METHOD_DH`
* `crypto.constants.ENGINE_MET... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
52512c8f-8bc1-543a-8f5e-ea95eb9dbf50 | docs | nodejs | nodejs_crypto | 10x | 139 | ### crypto.setFips(bool)[#](#crypto_crypto_setfips_bool)
Added in: v10.0.0
* `bool` [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` to enable FIPS mode.
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
Throws an error if FIPS mode is... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
eeeb1a32-4724-5075-b9af-2cce2c89bdc3 | docs | nodejs | nodejs_crypto | 10x | 140 | * Returns: [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
This function is based on a constant-time algorithm.
Returns true if `a` is equal to `b`, without leaking timing information that
would allow an attacker to guess one of the values. This is suitable for
compari... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
b2794357-29bb-5f87-b0dd-5a7591790871 | docs | nodejs | nodejs_crypto | 10x | 141 | binary data. As such, the many of the `crypto` defined classes have methods not
typically found on other Node.js classes that implement the [streams](stream.html)
API (e.g. `update()`, `final()`, or `digest()`). Also, many methods accepted
and returned `'latin1'` encoded strings by default rather than `Buffer`s. This
d... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
af128aca-4685-57ee-9f3d-a2129f792b7d | docs | nodejs | nodejs_crypto | 10x | 142 | The [`ecdh.setPublicKey()`](#crypto_ecdh_setpublickey_publickey_encoding) method is now deprecated as its inclusion in the
API is not useful. Either a previously stored private key should be set, which
automatically generates the associated public key, or [`ecdh.generateKeys()`](#crypto_ecdh_generatekeys_encoding_forma... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
7571de3d-2131-5938-acb9-21d464e6dae1 | docs | nodejs | nodejs_crypto | 10x | 143 | Based on the recommendations of [NIST SP 800-131A](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf):
* MD5 and SHA-1 are no longer acceptable where collision resistance is
required such as digital signatures.
* The key used with RSA, DSA, and DH algorithms is recommended to have
at lea... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
009f3c15-585e-5727-9b44-7b374f8093ca | docs | nodejs | nodejs_crypto | 10x | 144 | * The length of the initialization vector (nonce) `N` must be between 7 and 13
bytes (`7 ≤ N ≤ 13`).
* The length of the plaintext is limited to `2 ** (8 * (15 - N))` bytes.
* When decrypting, the authentication tag must be set via `setAuthTag()` before
specifying additional authenticated data or calling `update()`... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
86a7d5ab-ce9d-5f41-806b-08600e8d032d | docs | nodejs | nodejs_crypto | 10x | 145 | applications *must* call `final()` to compute or verify the
authentication tag.
```None
const crypto = require('crypto');
const key = 'keykeykeykeykeykeykeykey';
const nonce = crypto.randomBytes(12);
const aad = Buffer.from('0123456789', 'hex');
const cipher = crypto.createCipheriv('aes-192-ccm', key, nonce, {
... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
f0d5540d-e257-5c3d-bae9-964626574dd6 | docs | nodejs | nodejs_crypto | 10x | 146 | ## Crypto Constants[#](#crypto_crypto_constants_1)
The following constants exported by `crypto.constants` apply to various uses of
the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
### OpenSSL Options[#](#crypto_openssl_options)
| Constant | Description |
| --- | --- |
| `SSL_OP_ALL` | ... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
78f01b50-0cf0-51b9-8347-75885cbd37d2 | docs | nodejs | nodejs_crypto | 10x | 147 | | `SSL_OP_COOKIE_EXCHANGE` | Instructs OpenSSL to turn on cookie exchange. |
| `SSL_OP_CRYPTOPRO_TLSEXT_BUG` | Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. |
| `SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS` | Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround ... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a7ab5395-2b32-5f61-aec1-35da0c089dda | docs | nodejs | nodejs_crypto | 10x | 148 | | `SSL_OP_NO_COMPRESSION` | Instructs OpenSSL to disable support for SSL/TLS compression. |
| `SSL_OP_NO_QUERY_MTU` | |
| `SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION` | Instructs OpenSSL to always start a new session when performing renegotiation. |
| `SSL_OP_NO_SSLv2` | Instructs OpenSSL to turn off SSL v2 |
| `SS... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
d8c047f6-b92b-54bd-9d40-7ee5d2ad594f | docs | nodejs | nodejs_crypto | 10x | 149 | | `SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG` | |
| `SSL_OP_TLS_BLOCK_PADDING_BUG` | |
| `SSL_OP_TLS_D5_BUG` | |
| `SSL_OP_TLS_ROLLBACK_BUG` | Instructs OpenSSL to disable version rollback attack detection. |
### OpenSSL Engine Constants[#](#crypto_openssl_engine_constants)
| Constant | Description |
| --- | --- |
| `ENG... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
b681d3cc-cb00-57e4-9493-1daa9b701613 | docs | nodejs | nodejs_crypto | 10x | 150 | ### Other OpenSSL Constants[#](#crypto_other_openssl_constants)
| Constant | Description |
| --- | --- |
| `DH_CHECK_P_NOT_SAFE_PRIME` | |
| `DH_CHECK_P_NOT_PRIME` | |
| `DH_UNABLE_TO_CHECK_GENERATOR` | |
| `DH_NOT_SUITABLE_GENERATOR` | |
| `ALPN_ENABLED` | |
| `RSA_PKCS1_PADDING` | |
| `RSA_SSLV23_PADDING` | |... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
8f9faaed-1d4d-59a4-a5f4-2c6ed66d0a98 | docs | nodejs | nodejs_crypto | 10x | 151 | ### Node.js Crypto Constants[#](#crypto_node_js_crypto_constants)
| Constant | Description |
| --- | --- |
| `defaultCoreCipherList` | Specifies the built-in default cipher list used by Node.js. |
| `defaultCipherList` | Specifies the active default cipher list used by the current Node.js process. |
| large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
f567de6d-48ad-5a07-9d26-6185c263f825 | docs | nodejs | nodejs_crypto | 11x | 0 | # Crypto#
Source: https://nodejs.org/docs/latest-v11.x/api/crypto.html
Version: 11.x
[Stability: 2](documentation.html#documentation_stability_index) - Stable
The `crypto` module provides cryptographic functionality that includes a set of
wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify function... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
62200b83-ae09-57c9-a0ce-06838e5793c5 | docs | nodejs | nodejs_crypto | 11x | 1 | } catch (err) {
console.log('crypto support is disabled!');
}
```
## Class: Certificate[#](#crypto_class_certificate)
Added in: v0.11.8
SPKAC is a Certificate Signing Request mechanism originally implemented by
Netscape and was specified formally as part of [HTML5's `keygen` element](https://developer.mozilla.org/... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
7a7a38d4-d0d0-5b20-8646-27a1a977852a | docs | nodejs | nodejs_crypto | 11x | 2 | ### Certificate.exportChallenge(spkac)[#](#crypto_certificate_exportchallenge_spkac)
Added in: v9.0.0
* `spkac` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/Ja... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4c5608a3-e372-52f1-b910-b8a4cf3d8f11 | docs | nodejs | nodejs_crypto | 11x | 3 | ### Certificate.exportPublicKey(spkac[, encoding])[#](#crypto_certificate_exportpublickey_spkac_encoding)
Added in: v9.0.0
* `spkac` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
476be391-a607-5741-b755-a8ae3c9d1c59 | docs | nodejs | nodejs_crypto | 11x | 4 | // Prints: the public key as <Buffer ...>
```
### Certificate.verifySpkac(spkac)[#](#crypto_certificate_verifyspkac_spkac)
Added in: v9.0.0
* `spkac` [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6eb9df47-f840-5be1-8038-9295f6226d55 | docs | nodejs | nodejs_crypto | 11x | 5 | #### new crypto.Certificate()[#](#crypto_new_crypto_certificate)
Instances of the `Certificate` class can be created using the `new` keyword
or by calling `crypto.Certificate()` as a function:
```None
const crypto = require('crypto');
const cert1 = new crypto.Certificate();
const cert2 = crypto.Certificate();
```
#... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
2c58cd10-706c-50a8-8f26-67d4ab981a22 | docs | nodejs | nodejs_crypto | 11x | 6 | const spkac = getSpkacSomehow();
const challenge = cert.exportChallenge(spkac);
console.log(challenge.toString('utf8'));
// Prints: the challenge as a UTF8 string
```
#### certificate.exportPublicKey(spkac)[#](#crypto_certificate_exportpublickey_spkac)
Added in: v0.11.8
* `spkac` [<string>](https://developer.mozilla... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1fe79dd4-3ce4-50a3-8c4e-534677903b52 | docs | nodejs | nodejs_crypto | 11x | 7 | #### certificate.verifySpkac(spkac)[#](#crypto_certificate_verifyspkac_spkac_1)
Added in: v0.11.8
* `spkac` [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
15ceffc6-b62e-5942-8d74-84e9aa0658b7 | docs | nodejs | nodejs_crypto | 11x | 8 | data is written to produce encrypted data on the readable side, or
* Using the [`cipher.update()`](#crypto_cipher_update_data_inputencoding_outputencoding) and [`cipher.final()`](#crypto_cipher_final_outputencoding) methods to produce
the encrypted data.
The [`crypto.createCipher()`](#crypto_crypto_createcipher_al... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
bc9fbf94-4d74-5c91-a106-bb9dc4893993 | docs | nodejs | nodejs_crypto | 11x | 9 | const iv = Buffer.alloc(16, 0); // Initialization vector.
const cipher = crypto.createCipheriv(algorithm, key, iv);
let encrypted = '';
cipher.on('readable', () => {
let chunk;
while (null !== (chunk = cipher.read())) {
encrypted += chunk.toString('hex');
}
});
cipher.on('end', () => {
console.log(encrypt... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
f7c055e0-b865-5dd3-b010-3533e9e11cd4 | docs | nodejs | nodejs_crypto | 11x | 10 | const output = fs.createWriteStream('test.enc');
input.pipe(cipher).pipe(output);
```
Example: Using the [`cipher.update()`](#crypto_cipher_update_data_inputencoding_outputencoding) and [`cipher.final()`](#crypto_cipher_final_outputencoding) methods:
```None
const crypto = require('crypto');
const algorithm = 'aes-... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
028c5999-1457-584f-976a-99f5d6757ffe | docs | nodejs | nodejs_crypto | 11x | 11 | ### cipher.final([outputEncoding])[#](#crypto_cipher_final_outputencoding)
Added in: v0.1.94
* `outputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the return value.
* Returns: [<Buffer>](... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
11ac4d59-d9c1-5357-b6fb-ff5bbfb68b5f | docs | nodejs | nodejs_crypto | 11x | 12 | ### cipher.setAAD(buffer[, options])[#](#crypto_cipher_setaad_buffer_options)
Added in: v1.0.0
* `buffer` [<Buffer>](buffer.html#buffer_class_buffer)
* `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) [`stream.transform` options](stream.html#stream_new_stre... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
78b631b7-4684-5f68-9edb-96eb75db0dad | docs | nodejs | nodejs_crypto | 11x | 13 | The `cipher.setAAD()` method must be called before [`cipher.update()`](#crypto_cipher_update_data_inputencoding_outputencoding).
### cipher.getAuthTag()[#](#crypto_cipher_getauthtag)
Added in: v1.0.0
* Returns: [<Buffer>](buffer.html#buffer_class_buffer) When using an authenticated encryption mode (`GCM`, `CCM`
an... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
27d202f6-522c-5cbc-9c94-4fc144f4f14c | docs | nodejs | nodejs_crypto | 11x | 14 | When using block encryption algorithms, the `Cipher` class will automatically
add padding to the input data to the appropriate block size. To disable the
default padding call `cipher.setAutoPadding(false)`.
When `autoPadding` is `false`, the length of the entire input data must be a
multiple of the cipher's block size... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
10bdb5a7-b555-5d06-9f85-be43365da745 | docs | nodejs | nodejs_crypto | 11x | 15 | * `data` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/Web... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
56e3eeb5-7e2e-5ec8-8271-061dcf0307ea | docs | nodejs | nodejs_crypto | 11x | 16 | argument is a string using the specified encoding. If the `inputEncoding`
argument is not given, `data` must be a [`Buffer`](buffer.html), `TypedArray`, or
`DataView`. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or `DataView`, then
`inputEncoding` is ignored.
The `outputEncoding` specifies the output format ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
de08d1ec-6645-5a5a-abb3-9d61c39f4d69 | docs | nodejs | nodejs_crypto | 11x | 17 | * As a [stream](stream.html) that is both readable and writable, where plain encrypted
data is written to produce unencrypted data on the readable side, or
* Using the [`decipher.update()`](#crypto_decipher_update_data_inputencoding_outputencoding) and [`decipher.final()`](#crypto_decipher_final_outputencoding) metho... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
11cb0557-9cbb-5d07-beaf-05fddf551cf0 | docs | nodejs | nodejs_crypto | 11x | 18 | const key = crypto.scryptSync(password, 'salt', 24);
// The IV is usually passed along with the ciphertext.
const iv = Buffer.alloc(16, 0); // Initialization vector.
const decipher = crypto.createDecipheriv(algorithm, key, iv);
let decrypted = '';
decipher.on('readable', () => {
while (null !== (chunk = decipher.re... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
136d85f5-768c-53e1-9956-01a7c8a0ab72 | docs | nodejs | nodejs_crypto | 11x | 19 | const iv = Buffer.alloc(16, 0); // Initialization vector.
const decipher = crypto.createDecipheriv(algorithm, key, iv);
const input = fs.createReadStream('test.enc');
const output = fs.createWriteStream('test.js');
input.pipe(decipher).pipe(output);
```
Example: Using the [`decipher.update()`](#crypto_decipher_upda... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
921e5156-3136-57d5-91d4-e1e74014d5ea | docs | nodejs | nodejs_crypto | 11x | 20 | let decrypted = decipher.update(encrypted, 'hex', 'utf8');
decrypted += decipher.final('utf8');
console.log(decrypted);
// Prints: some clear text data
```
### decipher.final([outputEncoding])[#](#crypto_decipher_final_outputencoding)
Added in: v0.1.94
* `outputEncoding` [<string>](https://developer.mozilla.org/en-U... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b898d100-617f-5766-bd21-1ccb5730e633 | docs | nodejs | nodejs_crypto | 11x | 21 | ### decipher.setAAD(buffer[, options])[#](#crypto_decipher_setaad_buffer_options)
History
| Version | Changes |
| --- | --- |
| v7.2.0 | This method now returns a reference to `decipher`. |
| v1.0.0 | Added in: v1.0.0 |
* `buffer` [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b8556fc3-7ac6-5f4a-81ad-43ed2170b084 | docs | nodejs | nodejs_crypto | 11x | 22 | currently supported), the `decipher.setAAD()` method sets the value used for the
*additional authenticated data* (AAD) input parameter.
The `options` argument is optional for `GCM`. When using `CCM`, the
`plaintextLength` option must be specified and its value must match the length
of the plaintext in bytes. See [CCM ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
220f4084-036d-5015-860f-79b92d3849cf | docs | nodejs | nodejs_crypto | 11x | 23 | * `buffer` [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
* Returns: [<Decipher>](crypto.html#crypto_class_... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b693977d-ba71-5ac1-b9ee-a8e075b4c849 | docs | nodejs | nodejs_crypto | 11x | 24 | The `decipher.setAuthTag()` method must be called before
[`decipher.final()`](#crypto_decipher_final_outputencoding) and can only be called once.
### decipher.setAutoPadding([autoPadding])[#](#crypto_decipher_setautopadding_autopadding)
Added in: v0.7.1
* `autoPadding` [<boolean>](https://developer.mozilla.org/en-US... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
5537c0c2-4d42-5b29-9878-d1456e4beecd | docs | nodejs | nodejs_crypto | 11x | 25 | ### decipher.update(data[, inputEncoding][, outputencoding])[#](#crypto_decipher_update_data_inputencoding_outputencoding)
History
| Version | Changes |
| --- | --- |
| v6.0.0 | The default `inputEncoding` changed from `binary` to `utf8`. |
| v0.1.94 | Added in: v0.1.94 |
* `data` [<string>](https://developer.mozill... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
eb06096f-d2a1-5de1-a21c-2d629cbdd9b1 | docs | nodejs | nodejs_crypto | 11x | 26 | * `outputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the return value.
* Returns: [<Buffer>](buffer.html#buffer_class_buffer) | [<string>](https://developer.mozilla.org/en-US/docs/Web/Java... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d71582e7-a234-5ef3-9e66-b075e8e6a571 | docs | nodejs | nodejs_crypto | 11x | 27 | [`decipher.final()`](#crypto_decipher_final_outputencoding) is called. Calling `decipher.update()` after
[`decipher.final()`](#crypto_decipher_final_outputencoding) will result in an error being thrown.
## Class: DiffieHellman[#](#crypto_class_diffiehellman)
Added in: v0.5.0
The `DiffieHellman` class is a utility fo... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ec6e7156-a6d9-557a-bb95-850b5ca37a46 | docs | nodejs | nodejs_crypto | 11x | 28 | // OK
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
```
### diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputencoding])[#](#crypto_diffiehellman_computesecret_otherpublickey_inputencoding_outputencoding)
Added in: v0.5.0
* `otherPublicKey` [<string>](https://developer... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
f15f9dc2-ea6b-587c-b301-c09e328cf903 | docs | nodejs | nodejs_crypto | 11x | 29 | * `outputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the return value.
* Returns: [<Buffer>](buffer.html#buffer_class_buffer) | [<string>](https://developer.mozilla.org/en-US/docs/Web/Java... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4f962ea1-7567-506a-8990-026c11a6ed00 | docs | nodejs | nodejs_crypto | 11x | 30 | ### diffieHellman.generateKeys([encoding](buffer.html#buffer_buffers_and_character_encodings))[#](#crypto_diffiehellman_generatekeys_encoding)
Added in: v0.5.0
* `encoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_cha... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6ac87dce-ddde-5798-bc29-bdc6b1b30ece | docs | nodejs | nodejs_crypto | 11x | 31 | * `encoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the return value.
* Returns: [<Buffer>](buffer.html#buffer_class_buffer) | [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3226ef60-c6f0-553a-aa74-f3717cf6d09b | docs | nodejs | nodejs_crypto | 11x | 32 | Returns the Diffie-Hellman prime in the specified `encoding`.
If `encoding` is provided a string is
returned; otherwise a [`Buffer`](buffer.html) is returned.
### diffieHellman.getPrivateKey([encoding](buffer.html#buffer_buffers_and_character_encodings))[#](#crypto_diffiehellman_getprivatekey_encoding)
Added in: v0.5... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
88a8a549-d41b-5896-956a-54e7ab9b04cc | docs | nodejs | nodejs_crypto | 11x | 33 | ### diffieHellman.getPublicKey([encoding](buffer.html#buffer_buffers_and_character_encodings))[#](#crypto_diffiehellman_getpublickey_encoding)
Added in: v0.5.0
* `encoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_cha... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
28a4ab6c-1e7e-59e6-ab91-c0febc1f8323 | docs | nodejs | nodejs_crypto | 11x | 34 | * `privateKey` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/do... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
df66ec40-41be-5c43-8516-6d9333c5afdf | docs | nodejs | nodejs_crypto | 11x | 35 | ### diffieHellman.setPublicKey(publicKey[, encoding])[#](#crypto_diffiehellman_setpublickey_publickey_encoding)
Added in: v0.5.0
* `publicKey` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://develope... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
60a046aa-b577-5cfd-a718-5151bc31cdbb | docs | nodejs | nodejs_crypto | 11x | 36 | ### diffieHellman.verifyError[#](#crypto_diffiehellman_verifyerror)
Added in: v0.11.12
A bit field containing any warnings and/or errors resulting from a check
performed during initialization of the `DiffieHellman` object.
The following values are valid for this property (as defined in `constants`
module):
* `DH_CH... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
5bafb305-825c-52c0-ba15-e62c96ca2f8b | docs | nodejs | nodejs_crypto | 11x | 37 | // Exchange and generate the secret...
const aliceSecret = alice.computeSecret(bobKey);
const bobSecret = bob.computeSecret(aliceKey);
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
// OK
```
### Class Method: ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])[#](#cr... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
10509435-2e7b-5fe7-8241-3020c9494d8f | docs | nodejs | nodejs_crypto | 11x | 38 | * `inputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the `key` string.
* `outputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
defc8b27-4f41-56e6-958d-aeb38726ee1d | docs | nodejs | nodejs_crypto | 11x | 39 | using the specified `outputEncoding`.
Use [`crypto.getCurves()`](#crypto_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.
If `format` is not specified the point will be r... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ff1fd02b-81db-5b55-afd1-894df3344d8b | docs | nodejs | nodejs_crypto | 11x | 40 | console.log(uncompressedKey === ecdh.getPublicKey('hex'));
```
### ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputencoding])[#](#crypto_ecdh_computesecret_otherpublickey_inputencoding_outputencoding)
History
| Version | Changes |
| --- | --- |
| v10.0.0 | Changed error format to better support invalid pu... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c7b9cab3-0f27-519d-9066-9a37992d4530 | docs | nodejs | nodejs_crypto | 11x | 41 | * `inputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The [encoding](buffer.html#buffer_buffers_and_character_encodings) of the `otherPublicKey` string.
* `outputEncoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Strin... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
42961e32-b3e0-5611-af73-16ca4d96dcb7 | docs | nodejs | nodejs_crypto | 11x | 42 | If `outputEncoding` is given a string will be returned; otherwise a
[`Buffer`](buffer.html) is returned.
`ecdh.computeSecret` will throw an
`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`
lies outside of the elliptic curve. Since `otherPublicKey` is
usually supplied from a remote user over an insecure... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
17b08eed-e116-53b6-b1e2-feb5f22aaa23 | docs | nodejs | nodejs_crypto | 11x | 43 | 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.
The `format` argument specifies point encoding and can be `'compressed'` or
`'uncompressed'`. If `format` is not specified, the point will b... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c32ce9a9-4de4-59ac-8823-726ad154c23b | docs | nodejs | nodejs_crypto | 11x | 44 | If `encoding` is specified, a string is returned; otherwise a [`Buffer`](buffer.html) is
returned.
### ecdh.getPublicKey([encoding][, format])[#](#crypto_ecdh_getpublickey_encoding_format)
Added in: v0.11.14
* `encoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
f3936680-09ba-59b4-b22e-4f27ddd44425 | docs | nodejs | nodejs_crypto | 11x | 45 | If `encoding` is specified, a string is returned; otherwise a [`Buffer`](buffer.html) is
returned.
### ecdh.setPrivateKey(privateKey[, encoding])[#](#crypto_ecdh_setprivatekey_privatekey_encoding)
Added in: v0.11.14
* `privateKey` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Str... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
94b83368-21d1-5145-aa3b-414ed6858a4a | docs | nodejs | nodejs_crypto | 11x | 46 | If `privateKey` is not valid for the curve specified when the `ECDH` object was
created, an error is thrown. Upon setting the private key, the associated
public point (key) is also generated and set in the `ECDH` object.
### ecdh.setPublicKey(publicKey[, encoding])[#](#crypto_ecdh_setpublickey_publickey_encoding)
Add... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c5fb90f3-67ee-5ee2-bf63-ebef4f035e7d | docs | nodejs | nodejs_crypto | 11x | 47 | Sets the EC Diffie-Hellman public key.
If `encoding` is provided `publicKey` is expected to
be a string; otherwise a [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.
Note that there is not normally a reason to call this method because `ECDH`
only requires a private key and the other party's public key... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
24cfdda7-c4b8-5a10-91f1-f53124a73860 | docs | nodejs | nodejs_crypto | 11x | 48 | // application.
alice.setPrivateKey(
crypto.createHash('sha256').update('alice', 'utf8').digest()
);
// Bob uses a newly generated cryptographically strong
// pseudorandom key pair
bob.generateKeys();
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
const bobSecret = bob.computeSecret(alice... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
8aca1276-d019-57dd-9d78-816117676186 | docs | nodejs | nodejs_crypto | 11x | 49 | The [`crypto.createHash()`](#crypto_crypto_createhash_algorithm_options) method is used to create `Hash` instances. `Hash`
objects are not to be created directly using the `new` keyword.
Example: Using `Hash` objects as streams:
```None
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
hash... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
e5fc2d09-d15d-546e-b90d-be90856287b6 | docs | nodejs | nodejs_crypto | 11x | 50 |
```None
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
hash.update('some data to hash');
console.log(hash.digest('hex'));
// Prints:
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
```
### hash.digest([encoding](buffer.html#buffer_buffers_and_character_encodings))[#... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
bd6e5981-4269-55fb-a472-a4383458f339 | docs | nodejs | nodejs_crypto | 11x | 51 | The `Hash` object can not be used again after `hash.digest()` method has been
called. Multiple calls will cause an error to be thrown.
### hash.update(data[, inputEncoding])[#](#crypto_hash_update_data_inputencoding)
History
| Version | Changes |
| --- | --- |
| v6.0.0 | The default `inputEncoding` changed from `bin... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
f1059be8-0785-5b2e-9d36-5a8927009a94 | docs | nodejs | nodejs_crypto | 11x | 52 | 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`](buffer.html), `TypedArray`, or
`DataView`, then `inputEncoding` is ignored.
This can be called many times with new data as it is streamed.
## Class: Hmac[#](#crypto_cl... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
fd3ceff4-881e-5154-a966-14264d139332 | docs | nodejs | nodejs_crypto | 11x | 53 | const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', 'a secret');
hmac.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = hmac.read();
if (data) {
console.log(data.toString('hex'));
// Prints:
// 7fd04df92f636fd450bc841c941... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b3b238f6-3c84-5ea1-b1a6-40fed55de31f | docs | nodejs | nodejs_crypto | 11x | 54 | // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
```
### hmac.digest([encoding](buffer.html#buffer_buffers_and_character_encodings))[#](#crypto_hmac_digest_encoding)
Added in: v0.1.94
* `encoding` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ed4b4f83-d75a-5d90-aa8c-7b3480a565eb | docs | nodejs | nodejs_crypto | 11x | 55 | ### hmac.update(data[, inputEncoding])[#](#crypto_hmac_update_data_inputencoding)
History
| Version | Changes |
| --- | --- |
| v6.0.0 | The default `inputEncoding` changed from `binary` to `utf8`. |
| v0.1.94 | Added in: v0.1.94 |
* `data` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
fd4f9305-7c83-5eae-a3f6-d7573bf461f2 | docs | nodejs | nodejs_crypto | 11x | 56 | encoding of `'utf8'` is enforced. If `data` is a [`Buffer`](buffer.html), `TypedArray`, or
`DataView`, then `inputEncoding` is ignored.
This can be called many times with new data as it is streamed.
## Class: KeyObject[#](#crypto_class_keyobject)
History
| Version | Changes |
| --- | --- |
| v11.13.0 | This class i... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
033571c2-145b-5117-a239-443ff13ea9db | docs | nodejs | nodejs_crypto | 11x | 57 | ### keyObject.asymmetricKeyType[#](#crypto_keyobject_asymmetrickeytype)
Added in: v11.6.0
* [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
For asymmetric keys, this property represents the type of the embedded key
(`'rsa'`, `'dsa'` or `'ec'`). This property is `undefi... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
2217433f-74ca-58bc-aa5f-15c00816622c | docs | nodejs | nodejs_crypto | 11x | 58 | * `type`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be one of `'pkcs1'` (RSA only) or `'spki'`.
* `format`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be `'pem'` or `'der'`.
For private keys, the follow... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b9ae390f-e1b2-5a97-9207-5395dd4cd179 | docs | nodejs | nodejs_crypto | 11x | 59 | * `passphrase`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) The passphrase to use for encryption, see
`cipher`.
When PEM encoding was selected, the result will be a string, otherwise it will
be a buffer containing the d... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
66ee19c3-8305-5a65-a07d-b80bfb1dcbe2 | docs | nodejs | nodejs_crypto | 11x | 60 |
### keyObject.symmetricKeySize[#](#crypto_keyobject_symmetrickeysize)
Added in: v11.6.0
* [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
For secret keys, this property represents the size of the key in bytes. This
property is `undefined` for asymmetric keys.
### key... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
db1cdbb4-d295-5f74-b9aa-605e23f69fee | docs | nodejs | nodejs_crypto | 11x | 61 | * Using the [`sign.update()`](#crypto_sign_update_data_inputencoding) and [`sign.sign()`](#crypto_sign_sign_privatekey_outputencoding) methods to produce the
signature.
The [`crypto.createSign()`](#crypto_crypto_createsign_algorithm_options) method is used to create `Sign` instances. The
argument is the string name ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c8da3539-1663-50d2-be95-b2e6c4fb3935 | docs | nodejs | nodejs_crypto | 11x | 62 | Example: Using the [`sign.update()`](#crypto_sign_update_data_inputencoding) and [`verify.update()`](#crypto_verify_update_data_inputencoding) methods:
```None
const crypto = require('crypto');
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 2048,
});
const sign = crypto.create... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
e38aab74-60bb-5e5f-9da4-7abf216f6f17 | docs | nodejs | nodejs_crypto | 11x | 63 | * `privateKey` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<KeyObject>](crypto.html#crypto_class_keyobject)
+ `pad... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
f4b23647-1574-528a-8bf9-e6efab957c05 | docs | nodejs | nodejs_crypto | 11x | 64 | [`sign.update()`](#crypto_sign_update_data_inputencoding) or [`sign.write()`](stream.html#stream_writable_write_chunk_encoding_callback).
If `privateKey` is not a [`KeyObject`](#crypto_class_keyobject), this function behaves as if
`privateKey` had been passed to [`crypto.createPrivateKey()`](#crypto_crypto_createpriva... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
742fff4b-4f52-5f19-b5bb-c57d86837634 | docs | nodejs | nodejs_crypto | 11x | 65 | `RSA_PKCS1_PSS_PADDING`. The special value
`crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
maximum permissible value.
If `outputEncoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html)... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
2b66fdb3-10b6-53ad-9529-f6a591109789 | docs | nodejs | nodejs_crypto | 11x | 66 | * `data` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/Web... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
62e182c0-9fff-5869-a493-cbeab7720a2a | docs | nodejs | nodejs_crypto | 11x | 67 | ## Class: Verify[#](#crypto_class_verify)
Added in: v0.1.92
The `Verify` class is a utility for verifying signatures. It can be used in one
of two ways:
* As a writable [stream](stream.html) where written data is used to validate against the
supplied signature, or
* Using the [`verify.update()`](#crypto_verify_upd... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
8348067a-4efe-5a0e-a817-667fa3c4f244 | docs | nodejs | nodejs_crypto | 11x | 68 | * `data` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/Web... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
88d06d31-087d-5e58-89b0-b959b392e568 | docs | nodejs | nodejs_crypto | 11x | 69 | ### verify.verify(object, signature[, signatureEncoding])[#](#crypto_verify_verify_object_signature_signatureencoding)
History
| Version | Changes |
| --- | --- |
| v11.7.0 | The key can now be a private key. |
| v8.0.0 | Support for RSASSA-PSS and additional options was added. |
| v0.1.92 | Added in: v0.1.92 |
* `o... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
337935f0-875e-58a5-a35f-d06ca0388851 | docs | nodejs | nodejs_crypto | 11x | 70 | * `signature` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/doc... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ebe9fb32-96ae-5fbb-a42d-81cb4db7c6c8 | docs | nodejs | nodejs_crypto | 11x | 71 | `object` had been passed to [`crypto.createPublicKey()`](#crypto_crypto_createpublickey_key). If it is an
object, the following additional properties can be passed:
* `padding`: [<integer>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) - Optional padding value for RSA, one of the... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
310b3cee-c2b4-5797-84bc-07d0a6edf48a | docs | nodejs | nodejs_crypto | 11x | 72 | The `signature` argument is the previously calculated signature for the data, in
the `signatureEncoding`.
If a `signatureEncoding` is specified, the `signature` is expected to be a
string; otherwise `signature` is expected to be a [`Buffer`](buffer.html),
`TypedArray`, or `DataView`.
The `verify` object can not be use... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
e574480b-a828-5950-9e3b-93e10bd0fb58 | docs | nodejs | nodejs_crypto | 11x | 73 | ### crypto.DEFAULT\_ENCODING[#](#crypto_crypto_default_encoding)
Added in: v0.9.3Deprecated since: v10.0.0
[Stability: 0](documentation.html#documentation_stability_index) - Deprecated
The default encoding to use for functions that can take either strings
or [buffers](buffer.html). The default value is `'buffer'`, w... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1da7c896-3d9d-5d6a-b468-e0ad3799e5f7 | docs | nodejs | nodejs_crypto | 11x | 74 | `crypto.getFips()` instead.
### crypto.createCipher(algorithm, password[, options])[#](#crypto_crypto_createcipher_algorithm_password_options)
History
| Version | Changes |
| --- | --- |
| v10.10.0 | Ciphers in OCB mode are now supported. |
| v10.2.0 | The `authTagLength` option can now be used to produce shorter au... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
670b5156-8062-528d-b752-5abe3b2d3c37 | docs | nodejs | nodejs_crypto | 11x | 75 | * `password` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b24728af-1a7a-5e7a-991d-1cb00803dac9 | docs | nodejs | nodejs_crypto | 11x | 76 | option is not required but can be used to set the length of the authentication
tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
recent OpenSSL releases, `openssl list -cipher-algorithms`
(`openssl list-cipher-algorithms` for... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d250d99e-56b5-5a90-9a8d-ad557c80a371 | docs | nodejs | nodejs_crypto | 11x | 77 | non-cryptographically secure hash algorithm allow passwords to be tested very
rapidly.
In line with OpenSSL's recommendation to use a more modern algorithm instead of
[`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that developers derive a key and IV on
their own ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
72cc129c-b184-5338-8009-e19ff7dbb3bb | docs | nodejs | nodejs_crypto | 11x | 78 | ### crypto.createCipheriv(algorithm, key, iv[, options])[[src]](https://github.com/nodejs/node/blob/v11.15.0^0/lib/crypto.js#L111)[#](#crypto_crypto_createcipheriv_algorithm_key_iv_options)
History
| Version | Changes |
| --- | --- |
| v11.6.0 | The `key` argument can now be a `KeyObject`. |
| v11.2.0 | The cipher `c... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
25ce20fd-bf0f-5f46-9b14-a39c1bb98c97 | docs | nodejs | nodejs_crypto | 11x | 79 | * `key` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs/Web/... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
45b75470-fbeb-5a9a-a581-455856e169af | docs | nodejs | nodejs_crypto | 11x | 80 | * Returns: [<Cipher>](crypto.html#crypto_class_cipher)
Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
initialization vector (`iv`).
The `options` argument controls stream behavior and is optional except when a
cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the
`a... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
7a99408e-bd80-549d-9453-3500de4b0a93 | docs | nodejs | nodejs_crypto | 11x | 81 | [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded strings,
[Buffers](buffer.html), `TypedArray`, or `DataView`s. The `key` may optionally be
a [`KeyObject`](#crypto_class_keyobject) of type `secret`. If the cipher does not need
an initialization vector... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4855eba4-f960-594f-aa45-abe18ba8ad4e | docs | nodejs | nodejs_crypto | 11x | 82 | | v10.0.0 | Deprecated since: v10.0.0 |
| v0.1.94 | Added in: v0.1.94 |
[Stability: 0](documentation.html#documentation_stability_index) - Deprecated: Use [`crypto.createDecipheriv()`](#crypto_crypto_createdecipheriv_algorithm_key_iv_options) instead.
* `algorithm` [<string>](https://developer.mozilla.org/en-US/docs/... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6f7efd60-eb7c-58ae-9a68-3b299c14cd30 | docs | nodejs | nodejs_crypto | 11x | 83 | Creates and returns a `Decipher` object that uses the given `algorithm` and
`password` (key).
The `options` argument controls stream behavior and is optional except when a
cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the
`authTagLength` option is required and specifies the length of the
auth... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
9ed85349-4ec1-5100-af5d-6455f0302212 | docs | nodejs | nodejs_crypto | 11x | 84 | [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that developers derive a key and IV on
their own using [`crypto.scrypt()`](#crypto_crypto_scrypt_password_salt_keylen_options_callback) and to use [`crypto.createDecipheriv()`](#crypto_crypto_createdecipheriv_algorith... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.