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 |
|---|---|---|---|---|---|---|---|
7e699eac-0626-5982-8f59-df89f3455f98 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
22458e98-7958-55d3-9bc3-4011466f4e5e | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
c6c34e48-a8fc-5113-a4be-e92ea9ce9a23 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
4a990ee7-e626-5895-a9cd-e38e64e4ffd5 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
e467a376-34e3-5ee0-9922-b7724aeaaab6 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
e6aa9f79-d9d7-5a2f-a032-7e42a1330118 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
faf73cb7-2cd8-5ee7-ada0-ac43742bd70e | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
7a3a200d-499c-54e0-ba5e-26298536cd4b | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
b3daa896-9d17-5edc-8c9e-69c71e9f1aba | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
12c4fbcc-d383-5d08-a52f-ff6debdefa5c | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
42d0bc10-f5e3-5d1a-a588-0ca708f3a399 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
bcae69ca-8781-5597-ba9d-6d909fad40f9 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
fcf1bff1-d63f-5f60-926d-97c3cdfe1742 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
78dcffdd-5e29-5f12-b3c1-1ba9e654c508 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
2fa03993-812c-5787-840f-659dfebd5398 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
6b84f37e-a33e-58a3-b836-e0f469809c91 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
b7a196f0-2e74-5407-87ef-f502a7178e69 | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
10884e4b-7b99-5833-862c-669b0454745a | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
129d0d42-8a1c-5c2e-8da5-b5f7066a739b | docs | nodejs | nodejs_crypto | 10x | 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_10x.md |
51e8cd5f-de8f-5784-9ece-89b70bbb3e83 | docs | nodejs | nodejs_crypto | 10x | 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: Sign[#](#crypto_class_sign)
Added in: v0.1.92
The `Sign` Class is a utility for generating signatures. It c... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
7558f71e-a3f8-568e-a53a-f798453b13b4 | docs | nodejs | nodejs_crypto | 10x | 57 | const crypto = require('crypto');
const sign = crypto.createSign('SHA256');
sign.write('some data to sign');
sign.end();
const privateKey = getPrivateKeySomehow();
console.log(sign.sign(privateKey, 'hex'));
// Prints: the calculated signature using the specified private key and
// SHA-256. For RSA keys, the algorithm... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
b8e99e57-7ee0-5ab3-ac79-17ca3f5d7467 | docs | nodejs | nodejs_crypto | 10x | 58 | algorithm. This does not work for all signature algorithms, such as
'ecdsa-with-SHA256'. Use digest names instead.
Example: signing using legacy signature algorithm name
```None
const crypto = require('crypto');
const sign = crypto.createSign('RSA-SHA256');
sign.update('some data to sign');
const privateKey = getPr... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
9211ff10-81e6-5d6d-a01f-ef1c49acb53c | docs | nodejs | nodejs_crypto | 10x | 59 | + `passphrase` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
+ `padding` [<integer>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
+ `saltLength` [<integer>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
54718e68-c3e7-547c-ae23-bda4ef20d133 | docs | nodejs | nodejs_crypto | 10x | 60 | string, it is treated as a raw key with no passphrase. If `privateKey` is an
object, it must contain one or more of the following properties:
* `key`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded private key (required)
* `passphrase`: [<string>](https://... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
15378cae-a9d2-59c5-a42b-feef636d4d67 | docs | nodejs | nodejs_crypto | 10x | 61 | * `saltLength`: [<integer>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) - salt length for when padding is
`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_SIG... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
e7fa7fd3-e7d7-5ecd-87b4-26fb3332d49e | docs | nodejs | nodejs_crypto | 10x | 62 | * `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_10x.md |
a361f180-6c59-54fd-a40d-b76178148044 | docs | nodejs | nodejs_crypto | 10x | 63 | ## 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_10x.md |
20d3ffd3-ad6b-5a84-8bc0-4958bbc43859 | docs | nodejs | nodejs_crypto | 10x | 64 | Example: Using the [`verify.update()`](#crypto_verify_update_data_inputencoding) and [`verify.verify()`](#crypto_verify_verify_object_signature_signatureencoding) methods:
```None
const crypto = require('crypto');
const verify = crypto.createVerify('SHA256');
verify.update('some data to sign');
const publicKey = get... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
0ee5430a-d32e-5314-94e9-4a0970423d35 | docs | nodejs | nodejs_crypto | 10x | 65 | * `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_10x.md |
1fe94669-da69-532e-8750-c9b1d861d97f | docs | nodejs | nodejs_crypto | 10x | 66 | ### verify.verify(object, signature[, signatureEncoding])[#](#crypto_verify_verify_object_signature_signatureencoding)
History
| Version | Changes |
| --- | --- |
| v8.0.0 | Support for RSASSA-PSS and additional options was added. |
| v0.1.92 | Added in: v0.1.92 |
* `object` [<string>](https://developer.mozilla.org/... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a362c95e-198d-5a6b-b531-fa3eb7f0797d | docs | nodejs | nodejs_crypto | 10x | 67 | * `signatureEncoding` [<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 `signature` string.
* Returns: [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
481aeb1d-c4b9-50ff-8927-52f74e304113 | docs | nodejs | nodejs_crypto | 10x | 68 | + `crypto.constants.RSA_PKCS1_PADDING` (default)
+ `crypto.constants.RSA_PKCS1_PSS_PADDING`
Note that `RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function
used to verify the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt).
* `saltLength`: [<integer>](h... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
c9060700-d948-59c5-9f44-03cfe3dafb6a | docs | nodejs | nodejs_crypto | 10x | 69 | The `verify` object can not be used again after `verify.verify()` has been
called. Multiple calls to `verify.verify()` will result in an error being
thrown.
## `crypto` module methods and properties[#](#crypto_crypto_module_methods_and_properties)
### crypto.constants[#](#crypto_crypto_constants)
Added in: v6.3.0
*... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
910b54be-6057-5008-acbd-a284e1a0944e | docs | nodejs | nodejs_crypto | 10x | 70 | The `crypto.DEFAULT_ENCODING` mechanism is provided for backwards compatibility
with legacy programs that expect `'latin1'` to be the default encoding.
New applications should expect the default to be `'buffer'`.
This property is deprecated.
### crypto.fips[#](#crypto_crypto_fips)
Added in: v6.0.0Deprecated since: ... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a6f75ce3-9a18-57be-9cd4-4bf914c34e76 | docs | nodejs | nodejs_crypto | 10x | 71 | | v10.2.0 | The `authTagLength` option can now be used to produce shorter authentication tags in GCM mode and defaults to 16 bytes. |
| 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.createCipheriv()`](#c... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
6ee5fb36-f1da-5b65-9685-f1d1e8b4ea38 | docs | nodejs | nodejs_crypto | 10x | 72 | * `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) [`stream.transform` options](stream.html#stream_new_stream_transform_options)
* Returns: [<Cipher>](crypto.html#crypto_class_cipher)
Creates and returns a `Cipher` object that uses the given `algorithm` and
... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
ea443835-acf0-5db7-9513-542406c7e5de | docs | nodejs | nodejs_crypto | 10x | 73 | display the available cipher algorithms.
The `password` is used to derive the cipher key and initialization vector (IV).
The value must be either a `'latin1'` encoded string, a [`Buffer`](buffer.html), a
`TypedArray`, or a `DataView`.
The implementation of `crypto.createCipher()` derives keys using the OpenSSL
functi... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
256f8e83-b9b8-5f6a-85d1-2dc30549991e | docs | nodejs | nodejs_crypto | 10x | 74 | their own using [`crypto.scrypt()`](#crypto_crypto_scrypt_password_salt_keylen_options_callback) and to use [`crypto.createCipheriv()`](#crypto_crypto_createcipheriv_algorithm_key_iv_options)
to create the `Cipher` object. Users should not use ciphers with counter mode
(e.g. CTR, GCM, or CCM) in `crypto.createCipher()`... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
470c47d9-974b-5d5a-8701-b3260c89e5d0 | docs | nodejs | nodejs_crypto | 10x | 75 | | v10.2.0 | The `authTagLength` option can now be used to produce shorter authentication tags in GCM mode and defaults to 16 bytes. |
| v9.9.0 | The `iv` parameter may now be `null` for ciphers which do not need an initialization vector. |
| v0.1.94 | Added in: v0.1.94 |
* `algorithm` [<string>](https://developer.mozi... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
9c760970-46a9-5a2b-84a8-20355763f543 | docs | nodejs | nodejs_crypto | 10x | 76 | * `iv` [<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/J... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
37e3e128-d668-5e45-8b2f-a65bdc8ffd61 | docs | nodejs | nodejs_crypto | 10x | 77 | authentication tag in bytes, see [CCM mode](#crypto_ccm_mode). In GCM mode, the `authTagLength`
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
... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
1f6f7c71-b7e6-5d04-807c-912225e42764 | docs | nodejs | nodejs_crypto | 10x | 78 | added to ciphertext messages unencrypted. It may sound contradictory that
something has to be unpredictable and unique, but does not have to be secret;
it is important to remember that an attacker must not be able to predict ahead
of time what a given IV will be.
### crypto.createCredentials(details)[#](#crypto_crypto... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
2cd12ea6-d8c0-5669-aa6e-12e66ca942ef | docs | nodejs | nodejs_crypto | 10x | 79 | [`tls.createSecureContext()`](tls.html#tls_tls_createsecurecontext_options) which has the exact same arguments and return
value.
Returns a `tls.SecureContext`, as-if [`tls.createSecureContext()`](tls.html#tls_tls_createsecurecontext_options) had been
called.
### crypto.createDecipher(algorithm, password[, options])[[... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
ce16779a-68f0-592d-9c89-a804a1cd6d93 | docs | nodejs | nodejs_crypto | 10x | 80 | * `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_10x.md |
366ccf08-0d5f-5177-9809-0c20349341b1 | docs | nodejs | nodejs_crypto | 10x | 81 | The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
iteration, and no salt. The lack of salt allows dictionary attacks as the same
password always creates th... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
57e36771-4390-5426-a68c-320175df93c5 | docs | nodejs | nodejs_crypto | 10x | 82 | ### crypto.createDecipheriv(algorithm, key, iv[, options])[[src]](https://github.com/nodejs/node/blob/5182a7ece0b71feeb9157f7aa348a15d53e32058/lib/crypto.js#L116)[#](#crypto_crypto_createdecipheriv_algorithm_key_iv_options)
History
| Version | Changes |
| --- | --- |
| v10.17.0 | The cipher `chacha20-poly1305` is now... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
92bafc54-52cc-5e53-b4e8-159a5a951e56 | docs | nodejs | nodejs_crypto | 10x | 83 | * `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_10x.md |
abefbc05-4468-5e8f-a111-cd68dc3c3ac7 | docs | nodejs | nodejs_crypto | 10x | 84 | Creates and returns a `Decipher` object that uses 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
`authTagLength` option is required and specifies the... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
53dd5cb5-9bef-5e41-ba4a-868ff496f668 | docs | nodejs | nodejs_crypto | 10x | 85 | [Buffers](buffer.html), `TypedArray`, or `DataView`s. If the cipher does not need
an initialization vector, `iv` may be `null`.
Initialization vectors should be unpredictable and unique; ideally, they will be
cryptographically random. They do not have to be secret: IVs are typically just
added to ciphertext messages u... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
ff7f5acc-5898-5021-9c43-f19eb6599f7a | docs | nodejs | nodejs_crypto | 10x | 86 | | v6.0.0 | The default for the encoding parameters changed from `binary` to `utf8`. |
| v0.11.12 | Added in: v0.11.12 |
* `prime` [<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/... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
60d39ace-98ce-5e47-ae73-d6fb088fc9d1 | docs | nodejs | nodejs_crypto | 10x | 87 | * `generator` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | [<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/Java... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
4f22eb3f-5a2e-54b4-9df6-8998d763f3c4 | docs | nodejs | nodejs_crypto | 10x | 88 | If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
a [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.
If `generatorEncoding` is specified, `generator` is expected to be a string;
otherwise a number, [`Buffer`](buffer.html), `TypedArray`, or `DataView` is expected.
### cryp... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
cf43590a-8502-50ea-aca6-24d1df347ebf | docs | nodejs | nodejs_crypto | 10x | 89 | * `generator` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | [<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/Java... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
83aee0e8-be40-5e15-ac23-8ed4e6df8308 | docs | nodejs | nodejs_crypto | 10x | 90 | * `curveName` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [<ECDH>](crypto.html#crypto_class_ecdh)
Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
predefined curve specified by the `curveName` string. Use
[`crypto.getCurves()`]... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
e00d8b2b-4766-51ce-8b66-0ac4b793926d | docs | nodejs | nodejs_crypto | 10x | 91 | * `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) [`stream.transform` options](stream.html#stream_new_stream_transform_options)
* Returns: [<Hash>](crypto.html#crypto_class_hash)
Creates and returns a `Hash` object that can be used to generate hash digests
... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
052e74e1-71b1-53f0-aa90-bbf12f34eaeb | docs | nodejs | nodejs_crypto | 10x | 92 | // Only one element is going to be produced by the
// hash stream.
const data = input.read();
if (data)
hash.update(data);
else {
console.log(`${hash.digest('hex')} ${filename}`);
}
});
```
### crypto.createHmac(algorithm, key[, options])[[src]](https://github.com/nodejs/node/blob/5182a7ece0b71feeb... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
030b7d04-16aa-50b8-a129-569001c79ea6 | docs | nodejs | nodejs_crypto | 10x | 93 | * `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) [`stream.transform` options](stream.html#stream_new_stream_transform_options)
* Returns: [<Hmac>](crypto.html#crypto_class_hmac)
Creates and returns an `Hmac` object that uses the given `algorithm` and `key`... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
5b83454b-a5e5-5ae5-b8d0-fdf5b3bb23dd | docs | nodejs | nodejs_crypto | 10x | 94 | const input = fs.createReadStream(filename);
input.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = input.read();
if (data)
hmac.update(data);
else {
console.log(`${hmac.digest('hex')} ${filename}`);
}
});
```
### crypto.createSign(algorithm[, o... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
1f93d47f-5493-58ff-a64a-8ea4687e5914 | docs | nodejs | nodejs_crypto | 10x | 95 | Use [`crypto.getHashes()`](#crypto_crypto_gethashes) to obtain an array of names of the available
signing algorithms. Optional `options` argument controls the
`stream.Writable` behavior.
### crypto.createVerify(algorithm[, options])[[src]](https://github.com/nodejs/node/blob/5182a7ece0b71feeb9157f7aa348a15d53e32058/li... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
0985a604-ecc8-56b7-8a32-77dcc0810a44 | docs | nodejs | nodejs_crypto | 10x | 96 | `stream.Writable` behavior.
### crypto.generateKeyPair(type, options, callback)[#](#crypto_crypto_generatekeypair_type_options_callback)
Added in: v10.12.0
* `type`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be `'rsa'`, `'dsa'` or `'ec'`.
* `options`: [<Obje... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
833cda23-9eb6-51a9-b215-82835c8512be | docs | nodejs | nodejs_crypto | 10x | 97 | + `publicKeyEncoding`: [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
- `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://... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
e14a88eb-f12a-5942-822e-348bf851826b | docs | nodejs | nodejs_crypto | 10x | 98 | - `cipher`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) If specified, the private key will be encrypted with
the given `cipher` and `passphrase` using PKCS#5 v2.0 password based
encryption.
- `passphrase`: [<string>](https://developer.mozilla.org/e... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
d757b528-5ad1-5c1c-a864-641594503fde | docs | nodejs | nodejs_crypto | 10x | 99 | Generates a new asymmetric key pair of the given `type`. Only RSA, DSA and EC
are currently supported.
It is recommended to encode public keys as `'spki'` and private keys as
`'pkcs8'` with encryption:
```None
const { generateKeyPair } = require('crypto');
generateKeyPair('rsa', {
modulusLength: 4096,
publicKeyEn... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
008eb854-4b3b-52e2-84d2-e3e8ee86e03a | docs | nodejs | nodejs_crypto | 10x | 100 | If this method is invoked as its [`util.promisify()`](util.html#util_util_promisify_original)ed version, it returns
a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
### crypto.generateKeyPairSync(type, options)[#](#crypto_crypto_generatekeypairsync_type_options)
Added in: v10.12.0
* `type`: ... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
4272a346-e45a-5eb3-a168-7365a7351ce8 | docs | nodejs | nodejs_crypto | 10x | 101 | + `namedCurve`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Name of the curve to use (EC).
+ `publicKeyEncoding`: [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
- `type`: [<string>](https://developer.mozill... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
93750670-dc29-5fef-8c21-e1d2db3456a0 | docs | nodejs | nodejs_crypto | 10x | 102 | - `cipher`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) If specified, the private key will be encrypted with
the given `cipher` and `passphrase` using PKCS#5 v2.0 password based
encryption.
- `passphrase`: [<string>](https://developer.mozilla.org/e... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a33944d1-5d58-5379-aa0b-5abd70079f0b | docs | nodejs | nodejs_crypto | 10x | 103 | It is recommended to encode public keys as `'spki'` and private keys as
`'pkcs8'` with encryption:
```None
const { generateKeyPairSync } = require('crypto');
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKe... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a08354d7-a2a1-5d80-b5e2-2bf8c1bc0057 | docs | nodejs | nodejs_crypto | 10x | 104 | ### crypto.getCurves()[#](#crypto_crypto_getcurves)
Added in: v2.3.0
* Returns: [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) An array with the names of the supported elliptic curves.
```None
const curves = crypto.getCurves();
console.log(curves); // ['Oakley-EC2N-... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
8bd1826d-30f0-5a7d-b07a-7aed62dae758 | docs | nodejs | nodejs_crypto | 10x | 105 | `'modp16'`, `'modp17'`, `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The
returned object mimics the interface of objects created by
[`crypto.createDiffieHellman()`](#crypto_crypto_creatediffiehellman_prime_primeencoding_generator_generatorencoding), but will not allow changing
the key... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
55b05004-26fb-5565-8be4-7f6292a4f199 | docs | nodejs | nodejs_crypto | 10x | 106 | console.log(aliceSecret === bobSecret);
```
### crypto.getFips()[#](#crypto_crypto_getfips)
Added in: v10.0.0
* Returns: [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` if and only if a FIPS compliant crypto provider is
currently in use.
### crypto.getHashe... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
c5bd5b94-b0c3-517e-80c0-bfcb714c7401 | docs | nodejs | nodejs_crypto | 10x | 107 | | v6.0.0 | Calling this function without passing the `digest` parameter is deprecated now and will emit a warning. |
| v6.0.0 | The default encoding for `password` if it is a string changed from `binary` to `utf8`. |
| v0.5.5 | Added in: v0.5.5 |
* `password` [<string>](https://developer.mozilla.org/en-US/docs/Web/Jav... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
e997c412-8ba2-5472-bec6-4cc89a9b5193 | docs | nodejs | nodejs_crypto | 10x | 108 | * `iterations` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
* `keylen` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
* `digest` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_t... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
79371644-47ce-565e-9a1d-7b1e65715169 | docs | nodejs | nodejs_crypto | 10x | 109 | otherwise `err` will be `null`. By default, the successfully generated
`derivedKey` will be passed to the callback as a [`Buffer`](buffer.html). An error will be
thrown if any of the input arguments specify invalid values or types.
If `digest` is `null`, `'sha1'` will be used. This behavior will be deprecated
in a fut... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
757511d8-ad10-5104-8bba-f4538fd986a4 | docs | nodejs | nodejs_crypto | 10x | 110 | The `crypto.DEFAULT_ENCODING` property can be used to change the way the
`derivedKey` is passed to the callback. This property, however, has been
deprecated and use should be avoided.
```None
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'hex';
crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err,... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
b710c320-e034-554e-aa41-6003332d5c3b | docs | nodejs | nodejs_crypto | 10x | 111 | | v6.0.0 | Calling this function without passing the `digest` parameter is deprecated now and will emit a warning. |
| v6.0.0 | The default encoding for `password` if it is a string changed from `binary` to `utf8`. |
| v0.9.3 | Added in: v0.9.3 |
* `password` [<string>](https://developer.mozilla.org/en-US/docs/Web/Jav... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
5e1cf8c2-dbe7-5e30-a57a-db327988c33a | docs | nodejs | nodejs_crypto | 10x | 112 | * `iterations` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
* `keylen` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
* `digest` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_t... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
8f4d9e31-d9b2-5dbd-9b14-b6d6e298c752 | docs | nodejs | nodejs_crypto | 10x | 113 | but will take a longer amount of time to complete.
The `salt` should be as unique as possible. It is recommended that a salt is
random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
```None
const crypto = require('crypto');... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
b0bffee9-e7d3-5656-8341-a28df4bb81d2 | docs | nodejs | nodejs_crypto | 10x | 114 | ### crypto.privateDecrypt(privateKey, buffer)[#](#crypto_crypto_privatedecrypt_privatekey_buffer)
Added in: v0.11.14
* `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#S... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
94a22a1b-76c1-58d9-aa94-eccf2191ba71 | docs | nodejs | nodejs_crypto | 10x | 115 | * `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: [<Buffer>](buffer.html#buffer_class_bu... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
7ed951d9-3153-5dae-a7f0-3c70b985f471 | docs | nodejs | nodejs_crypto | 10x | 116 | * `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)
+ `key` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) ... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
f59513a4-2ade-5a2b-9914-efb0165a7ada | docs | nodejs | nodejs_crypto | 10x | 117 | * Returns: [<Buffer>](buffer.html#buffer_class_buffer) A new `Buffer` with the encrypted content.
Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
the corresponding public key, for example using [`crypto.publicDecrypt()`](#crypto_crypto_publicdecrypt_key_buffer).
`privateKey` can be an ob... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
aa4c356e-297e-5923-88aa-7136c5ea4768 | docs | nodejs | nodejs_crypto | 10x | 118 | + `passphrase` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) An optional passphrase for the private key.
+ `padding` [<crypto.constants>](crypto.html#crypto_crypto_constants_1) An optional padding value defined in
`crypto.constants`, which may be: `crypto.consta... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a5f26d06-6e2b-5126-a6cf-e7a7c2a1e543 | docs | nodejs | nodejs_crypto | 10x | 119 | `key` can be an object or a string. If `key` is a string, it is treated as
the key with no passphrase and will use `RSA_PKCS1_PADDING`.
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
### crypto.publicEncrypt(key, buffer)[#](#crypto_crypto_publicencrypt_k... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
4a34cc3d-89cc-50bb-88b7-14a91463b163 | docs | nodejs | nodejs_crypto | 10x | 120 | `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`crypto.constants.RSA_PKCS1_PADDING`, or
`crypto.constants.RSA_PKCS1_OAEP_PADDING`.
* `buffer` [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Ty... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
acf77a41-99f5-5474-a2fe-4eca9d95563a | docs | nodejs | nodejs_crypto | 10x | 121 | Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
### crypto.randomBytes(size[, callback])[#](#crypto_crypto_randombytes_size_callback)
History
| Version | Changes |
| --- | --- |
| v9.0.0 | Passing `null` as the `callback` argument now throws `ERR_INVALID... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
a8691a05-800f-5054-89c3-d98f491f6de1 | docs | nodejs | nodejs_crypto | 10x | 122 | If a `callback` function is provided, the bytes are generated asynchronously
and the `callback` function is invoked with two arguments: `err` and `buf`.
If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The
`buf` argument is a [`Buffer`](buffer.html) containing the generated bytes.
```None
/... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
f4d4dd45-4577-58fe-9ae3-395282d12fc7 | docs | nodejs | nodejs_crypto | 10x | 123 | This should normally never take longer than a few milliseconds. The only time
when generating the random bytes may conceivably block for a longer period of
time is right after boot, when the whole system is still low on entropy.
Note that this API uses libuv's threadpool, which can have surprising and
negative perform... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
fc562b8e-7c6b-58be-b3a8-615b0fbf38b8 | docs | nodejs | nodejs_crypto | 10x | 124 | * `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) Must be supplied.
* `offset` [<number>](https://d... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
1b0fd10f-ec9e-5f46-8620-8e017b0ce9e2 | docs | nodejs | nodejs_crypto | 10x | 125 | console.log(crypto.randomFillSync(buf).toString('hex'));
crypto.randomFillSync(buf, 5);
console.log(buf.toString('hex'));
// The above is equivalent to the following:
crypto.randomFillSync(buf, 5, 5);
console.log(buf.toString('hex'));
```
Any `TypedArray` or `DataView` instance may be passed as `buffer`.
```None
co... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
1dd71507-f5cf-5f39-a4ae-e33f278978c5 | docs | nodejs | nodejs_crypto | 10x | 126 | ### crypto.randomFill(buffer[, offset][, size], callback)[#](#crypto_crypto_randomfill_buffer_offset_size_callback)
History
| Version | Changes |
| --- | --- |
| v9.0.0 | The `buffer` argument may be any `TypedArray` or `DataView`. |
| v7.10.0, v6.13.0 | Added in: v7.10.0, v6.13.0 |
* `buffer` [<Buffer>](buffer.html... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
65bf50ab-7f32-5daa-8a1c-f1c901d15da1 | docs | nodejs | nodejs_crypto | 10x | 127 | This function is similar to [`crypto.randomBytes()`](#crypto_crypto_randombytes_size_callback) but requires the first
argument to be a [`Buffer`](buffer.html) that will be filled. It also
requires that a callback is passed in.
If the `callback` function is not provided, an error will be thrown.
```None
const buf = Bu... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
ffaea92b-f382-52c4-b23b-ae326d3c52a1 | docs | nodejs | nodejs_crypto | 10x | 128 | crypto.randomFill(b, (err, buf) => {
if (err) throw err;
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
.toString('hex'));
});
const c = new DataView(new ArrayBuffer(10));
crypto.randomFill(c, (err, buf) => {
if (err) throw err;
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.b... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
89b4b194-cfc5-55d3-af01-469b9ab6b18c | docs | nodejs | nodejs_crypto | 10x | 129 | ### crypto.scrypt(password, salt, keylen[, options], callback)[#](#crypto_crypto_scrypt_password_salt_keylen_options_callback)
History
| Version | Changes |
| --- | --- |
| v10.17.0 | The `maxmem` value can now be any safe integer. |
| v10.9.0 | The `cost`, `blockSize` and `parallelization` option names have been add... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
5abf2f85-b899-5046-9a18-7ae76e54c1dd | docs | nodejs | nodejs_crypto | 10x | 130 | * `salt` [<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_10x.md |
fe02baed-0249-5358-ba8e-e7d7f70e6481 | docs | nodejs | nodejs_crypto | 10x | 131 | + `blockSize` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Block size parameter. **Default:** `8`.
+ `parallelization` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Parallelization parameter. **Default:** `1`.
+ `... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
6ef1371d-2396-5788-9e02-f5bfc9175839 | docs | nodejs | nodejs_crypto | 10x | 132 | `128 * N * r > maxmem`. **Default:** `32 * 1024 * 1024`.
* `callback` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
+ `err` [<Error>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
+ `derivedKey` [<Buffer>](buffe... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
14cf035e-d22d-528b-b0a8-ae2257027509 | docs | nodejs | nodejs_crypto | 10x | 133 | `null`. `derivedKey` is passed to the callback 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.
crypto.scrypt('secret', 'salt', 64, (err, derivedKey) => {
if (err) throw err;... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
4163287b-8e17-5b85-ae13-3091b521d154 | docs | nodejs | nodejs_crypto | 10x | 134 | * `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_10x.md |
94ed01f2-07ec-571b-acf0-7bb85f304101 | docs | nodejs | nodejs_crypto | 10x | 135 | + `cost` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) CPU/memory cost parameter. Must be a power of two greater
+ `N` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) CPU/memory cost parameter. Must be a power of two g... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
0a457d77-301a-5b79-a477-954da74306ab | docs | nodejs | nodejs_crypto | 10x | 136 | + `p` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Alias for `parallelization`. Only one of both may be specified.
+ `maxmem` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Memory upper bound. It is an error when (ap... | large_dataset/raw/docs/nodejs/crypto/crypto_10x.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.