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 |
|---|---|---|---|---|---|---|---|
8c991d89-ba1d-5177-ac66-3141fb69143d | docs | nodejs | nodejs_crypto | 4x | 25 | ```
Example: Using `Hash` and piped streams:
```None
const crypto = require('crypto');
const fs = require('fs');
const hash = crypto.createHash('sha256');
const input = fs.createReadStream('test.js');
input.pipe(hash).pipe(process.stdout);
```
Example: Using the [`hash.update()`](#crypto_hash_update_data_input_enco... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
5c5b811e-3fe0-5d1c-89dc-35c19c2db6f7 | docs | nodejs | nodejs_crypto | 4x | 26 | 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[, input\_encoding])[#](#crypto_hash_update_data_input_encoding)
Added in: v0.1.92
Updates the hash content with the given `data`, the encoding of which
is given ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
bc134155-5304-5d7a-8cd1-2c1edbbc3322 | docs | nodejs | nodejs_crypto | 4x | 27 | * Using the [`hmac.update()`](#crypto_hmac_update_data) and [`hmac.digest()`](#crypto_hmac_digest_encoding) methods to produce the
computed HMAC digest.
The [`crypto.createHmac()`](#crypto_crypto_createhmac_algorithm_key) method is used to create `Hmac` instances. `Hmac`
objects are not to be created directly using ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
c2812a19-e037-5375-9c69-2e5e0af106ef | docs | nodejs | nodejs_crypto | 4x | 28 | Example: Using the [`hmac.update()`](#crypto_hmac_update_data) and [`hmac.digest()`](#crypto_hmac_digest_encoding) methods:
```None
const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', 'a secret');
hmac.update('some data to hash');
console.log(hmac.digest('hex'));
// Prints:
// 7fd04df92f6... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
44fb6aaf-e0c0-574a-8b57-43982235376d | docs | nodejs | nodejs_crypto | 4x | 29 | ### hmac.update(data[, input\_encoding])[#](#crypto_hmac_update_data_input_encoding)
Added in: v0.1.94
Updates the `Hmac` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
`'binary'`. If `encoding` is not provided, and the `data` is a string, an
encodi... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
ea4363f7-8868-532a-b7d1-d0b9de3e67b3 | docs | nodejs | nodejs_crypto | 4x | 30 | The [`crypto.createSign()`](#crypto_crypto_createsign_algorithm) method is used to create `Sign` instances. `Sign`
objects are not to be created directly using the `new` keyword.
Example: Using `Sign` objects as streams:
```None
const crypto = require('crypto');
const sign = crypto.createSign('RSA-SHA256');
sign.wri... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
108e0a54-d58c-5581-99d2-a0c9934dd2a0 | docs | nodejs | nodejs_crypto | 4x | 31 | algorithm name, in which case OpenSSL will infer the full signature algorithm
from the type of the PEM-formatted private key, including algorithms that
do not have directly exposed name constants, e.g. 'ecdsa-with-SHA256'.
Example: signing using ECDSA with SHA256
```None
const crypto = require('crypto');
const sign =... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
d8409990-f4b0-5669-b1fb-0b1b160b0a9f | docs | nodejs | nodejs_crypto | 4x | 32 | [`sign.update()`](#crypto_sign_update_data) or [`sign.write()`](stream.html#stream_writable_write_chunk_encoding_callback).
The `private_key` argument can be an object or a string. If `private_key` is a
string, it is treated as a raw key with no passphrase. If `private_key` is an
object, it is interpreted as a hash co... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
ef5f7633-73df-55c7-ac1c-8cf1545c2987 | docs | nodejs | nodejs_crypto | 4x | 33 | ### sign.update(data[, input\_encoding])[#](#crypto_sign_update_data_input_encoding)
Added in: v0.1.92
Updates the `Sign` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
`'binary'`. If `encoding` is not provided, and the `data` is a string, an
encodi... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
cfe572ed-2f4d-5d21-aa8a-a3bf9eff7929 | docs | nodejs | nodejs_crypto | 4x | 34 | `Verify` objects are not to be created directly using the `new` keyword.
Example: Using `Verify` objects as streams:
```None
const crypto = require('crypto');
const verify = crypto.createVerify('RSA-SHA256');
verify.write('some data to sign');
verify.end();
const public_key = getPublicKeySomehow();
const signature ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
d69e5f73-a540-528e-afbe-bc69861debc7 | docs | nodejs | nodejs_crypto | 4x | 35 | ### verifier.update(data[, input\_encoding])[#](#crypto_verifier_update_data_input_encoding)
Added in: v0.1.92
Updates the `Verify` content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
`'binary'`. If `encoding` is not provided, and the `data` is a string,... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
c23bf78b-0359-5300-ab77-f0a5c88b10f0 | docs | nodejs | nodejs_crypto | 4x | 36 | If a `signature_format` is specified, the `signature` is expected to be a
string; otherwise `signature` is expected to be a [`Buffer`](buffer.html).
Returns `true` or `false` depending on the validity of the signature for
the data and public key.
The `verifier` object can not be used again after `verify.verify()` has... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
b0b7d410-2b5f-59ba-b0ca-015f0f71ee16 | docs | nodejs | nodejs_crypto | 4x | 37 | become deprecated in a future Node.js release.
### crypto.createCipher(algorithm, password)[#](#crypto_crypto_createcipher_algorithm_password)
Added in: v0.1.94
Creates and returns a `Cipher` object that uses the given `algorithm` and
`password`.
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
c663c45e-f3b5-5687-856b-8db7a2c9b63c | docs | nodejs | nodejs_crypto | 4x | 38 | non-cryptographically secure hash algorithm allow passwords to be tested very
rapidly.
In line with OpenSSL's recommendation to use pbkdf2 instead of
[`EVP_BytesToKey`](https://www.openssl.org/docs/man1.0.2/crypto/EVP_BytesToKey.html) it is recommended that developers derive a key and IV on
their own using [`crypto.pb... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
5559d417-fb0c-5c40-93ac-0ba143436d6b | docs | nodejs | nodejs_crypto | 4x | 39 | [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'binary'` encoded strings or
[buffers](buffer.html).
### crypto.createCredentials(details)[#](#crypto_crypto_createcredentials_details)
Added in: v0.1.92
Deprecated since: v0.11.13
```None
Stability: 0 - Deprecated:... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
083303dd-525a-5f75-b015-b6b2d2957016 | docs | nodejs | nodejs_crypto | 4x | 40 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - passphrase for the private key or PFX
* `cert` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded certificate
* `ca` : [<String>](https://develo... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
28b04542-a690-5c97-b747-4142efc665af | docs | nodejs | nodejs_crypto | 4x | 41 | * `ciphers`: [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) using the [OpenSSL cipher list format](https://www.openssl.org/docs/man1.0.2/apps/ciphers.html#CIPHER-LIST-FORMAT) describing the
cipher algorithms to use or exclude.
If no 'ca' details are given, Node.js wil... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
96bf743d-b80c-55ef-a0c5-0acad881ef93 | docs | nodejs | nodejs_crypto | 4x | 42 | password always creates the same key. The low iteration count and
non-cryptographically secure hash algorithm allow passwords to be tested very
rapidly.
In line with OpenSSL's recommendation to use pbkdf2 instead of
[`EVP_BytesToKey`](https://www.openssl.org/docs/man1.0.2/crypto/EVP_BytesToKey.html) it is recommended ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
c915eb8d-6c0c-5819-9e8e-50e28b772931 | docs | nodejs | nodejs_crypto | 4x | 43 | The `key` is the raw key used by the `algorithm` and `iv` is an
[initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'binary'` encoded strings or
[buffers](buffer.html).
### crypto.createDiffieHellman(prime[, prime\_encoding][, generator][, generator\_encoding])[#](#cry... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
e3392c91-fb62-5737-b87e-f22c26940051 | docs | nodejs | nodejs_crypto | 4x | 44 | otherwise either a number or [`Buffer`](buffer.html) is expected.
### crypto.createDiffieHellman(prime\_length[, generator])[#](#crypto_crypto_creatediffiehellman_prime_length_generator)
Added in: v0.5.0
Creates a `DiffieHellman` key exchange object and generates a prime of
`prime_length` bits using an optional spec... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
0fd38b1d-59ae-51bb-94c4-012663d42367 | docs | nodejs | nodejs_crypto | 4x | 45 | ### crypto.createHash(algorithm)[#](#crypto_crypto_createhash_algorithm)
Added in: v0.1.92
Creates and returns a `Hash` object that can be used to generate hash digests
using the given `algorithm`.
The `algorithm` is dependent on the available algorithms supported by the
version of OpenSSL on the platform. Examples ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
aceab5a6-7a8e-53ec-893f-3005a3702f40 | docs | nodejs | nodejs_crypto | 4x | 46 | ### crypto.createHmac(algorithm, key)[#](#crypto_crypto_createhmac_algorithm_key)
Added in: v0.1.94
Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
The `algorithm` is dependent on the available algorithms supported by the
version of OpenSSL on the platform. Examples are `'sha256'`, `'... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
5d842414-b4ea-508a-974a-39ba60c81ae7 | docs | nodejs | nodejs_crypto | 4x | 47 | ### crypto.createSign(algorithm)[#](#crypto_crypto_createsign_algorithm)
Added in: v0.1.92
Creates and returns a `Sign` object that uses the given `algorithm`.
Use [`crypto.getHashes()`](#crypto_crypto_gethashes) to obtain an array of names of the available
signing algorithms.
### crypto.createVerify(algorithm)[#](#... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
64dbe188-2b7c-5774-b622-8f055361735d | docs | nodejs | nodejs_crypto | 4x | 48 | ### crypto.getCurves()[#](#crypto_crypto_getcurves)
Added in: v2.3.0
Returns an array with the names of the supported elliptic curves.
Example:
```None
const curves = crypto.getCurves();
console.log(curves); // ['secp256k1', 'secp384r1', ...]
```
### crypto.getDiffieHellman(group\_name)[#](#crypto_crypto_getdiffie... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
45c0e9c5-c384-5d58-b577-7c83d187b86b | docs | nodejs | nodejs_crypto | 4x | 49 | the keys (with [`diffieHellman.setPublicKey()`](#crypto_diffiehellman_setpublickey_public_key_encoding) for example). The
advantage of using this method is that the parties do not have to
generate nor exchange a group modulus beforehand, saving both processor
and communication time.
Example (obtaining a shared secret)... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
7afae139-b6e4-5ee9-9181-fadc6c782fef | docs | nodejs | nodejs_crypto | 4x | 50 | console.log(hashes); // ['sha', 'sha1', 'sha1WithRSAEncryption', ...]
```
### crypto.pbkdf2(password, salt, iterations, keylen[, digest], callback)[#](#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback)
Added in: v0.5.5
Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
imp... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
25c58b53-064c-59af-b508-ed941911e34a | docs | nodejs | nodejs_crypto | 4x | 51 | The `salt` should also be as unique as possible. It is recommended that the
salts are random and their lengths are greater than 16 bytes. See
[NIST SP 800-132](http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf) for details.
Example:
```None
const crypto = require('crypto');
crypto.pbkdf2('secret',... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
9f0f6f18-a929-55e6-93db-b122fc04fdce | docs | nodejs | nodejs_crypto | 4x | 52 | `password`, `salt` and `iterations`. If the `digest` algorithm is not specified,
a default of `'sha1'` is used.
If an error occurs an Error will be thrown, otherwise the derived key will be
returned as a [`Buffer`](buffer.html).
The `iterations` argument must be a number set as high as possible. The
higher the number... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
08f55774-314e-52c1-8aa5-7ded5298e475 | docs | nodejs | nodejs_crypto | 4x | 53 | ### crypto.privateDecrypt(private\_key, buffer)[#](#crypto_crypto_privatedecrypt_private_key_buffer)
Added in: v0.11.14
Decrypts `buffer` with `private_key`.
`private_key` can be an object or a string. If `private_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
If... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
b3fc4fe6-f2a2-56be-be0d-c3b278a621d8 | docs | nodejs | nodejs_crypto | 4x | 54 | ### crypto.privateEncrypt(private\_key, buffer)[#](#crypto_crypto_privateencrypt_private_key_buffer)
Added in: v1.1.0
Encrypts `buffer` with `private_key`.
`private_key` can be an object or a string. If `private_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
If `priva... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
02ee588b-e7e7-5b4a-a9a5-a9f7e1917062 | docs | nodejs | nodejs_crypto | 4x | 55 | ### crypto.publicDecrypt(public\_key, buffer)[#](#crypto_crypto_publicdecrypt_public_key_buffer)
Added in: v1.1.0
Decrypts `buffer` with `public_key`.
`public_key` can be an object or a string. If `public_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
If `public_key` ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
12fe5509-889a-5ddf-a737-6f8a9d12241f | docs | nodejs | nodejs_crypto | 4x | 56 | ### crypto.publicEncrypt(public\_key, buffer)[#](#crypto_crypto_publicencrypt_public_key_buffer)
Added in: v0.11.14
Encrypts `buffer` with `public_key`.
`public_key` can be an object or a string. If `public_key` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
If `publi... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
81b22f70-fdbc-5b3b-b5a3-66f1396e732c | docs | nodejs | nodejs_crypto | 4x | 57 | ### crypto.randomBytes(size[, callback])[#](#crypto_crypto_randombytes_size_callback)
Added in: v0.5.8
Generates cryptographically strong pseudo-random data. The `size` argument
is a number indicating the number of bytes to generate.
If a `callback` function is provided, the bytes are generated asynchronously
and th... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
f9c1cb3c-d966-5c82-abd0-08c0357a3862 | docs | nodejs | nodejs_crypto | 4x | 58 | `${buf.length} bytes of random data: ${buf.toString('hex')}`);
```
The `crypto.randomBytes()` method will block until there is sufficient entropy.
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 ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
5ae66794-a17a-55e6-a3ec-1094a7e5f7c2 | docs | nodejs | nodejs_crypto | 4x | 59 | * `ENGINE_METHOD_STORE`
* `ENGINE_METHOD_PKEY_METH`
* `ENGINE_METHOD_PKEY_ASN1_METH`
* `ENGINE_METHOD_ALL`
* `ENGINE_METHOD_NONE`
## Notes[#](#crypto_notes)
### Legacy Streams API (pre Node.js v0.10)[#](#crypto_legacy_streams_api_pre_node_js_v0_10)
The Crypto module was added to Node.js before there was the concept ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
fd60b725-29d4-55e4-bbbb-f68cfa99a4b8 | docs | nodejs | nodejs_crypto | 4x | 60 | ### Recent ECDH Changes[#](#crypto_recent_ecdh_changes)
Usage of `ECDH` with non-dynamically generated key pairs has been simplified.
Now, [`ecdh.setPrivateKey()`](#crypto_ecdh_setprivatekey_private_key_encoding) can be called with a preselected private key
and the associated public point (key) will be computed and st... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
143b103b-7897-5f64-b669-4af454c15a3c | docs | nodejs | nodejs_crypto | 4x | 61 | it can be used to put the ECDH key pair into an inconsistent state.
### Support for weak or compromised algorithms[#](#crypto_support_for_weak_or_compromised_algorithms)
The `crypto` module still supports some algorithms which are already
compromised and are not currently recommended for use. The API also allows
the ... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
442fe17d-6b80-5176-a338-e9c7287639fd | docs | nodejs | nodejs_crypto | 4x | 62 | * The DH groups of `modp1`, `modp2` and `modp5` have a key size
smaller than 2048 bits and are not recommended.
See the reference for other recommendations and details.
| large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
333dd83f-7bf9-506e-bfdc-8eb60e05c4be | docs | nodejs | nodejs_crypto | 5x | 0 | # Crypto#
Source: https://nodejs.org/docs/latest-v5.x/api/crypto.html
Version: 5.x
```None
Stability: 2 - Stable
```
The `crypto` module provides cryptographic functionality that includes a set of
wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions.
Use `require('crypto')` to access this ... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
a72cc675-b175-578f-ac80-a9affeed3a96 | docs | nodejs | nodejs_crypto | 5x | 1 | data. The most common usage is handling output generated by the HTML5
`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation](https://www.openssl.org/docs/apps/spkac.html) internally.
### new crypto.Certificate()[#](#crypto_new_crypto_certificate)
Instances of the `Certificate` class can be created using th... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
44efad29-804a-5d6d-a89a-c214b0faa2a3 | docs | nodejs | nodejs_crypto | 5x | 2 | console.log(challenge.toString('utf8'));
// Prints the challenge as a UTF8 string
```
### certificate.exportPublicKey(spkac)[#](#crypto_certificate_exportpublickey_spkac)
The `spkac` data structure includes a public key and a challenge. The
`certificate.exportPublicKey()` returns the public key component in the
for... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
87aa0286-f234-5cf1-9336-ea0e5a0b0d7d | docs | nodejs | nodejs_crypto | 5x | 3 | // Prints true or false
```
## Class: Cipher[#](#crypto_class_cipher)
Instances of the `Cipher` class are used to encrypt data. The class can be
used in one of two ways:
* As a [stream](stream.html) that is both readable and writable, where plain unencrypted
data is written to produce encrypted data on the reada... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
4f6bef64-1be0-530d-ade5-6556d02c1137 | docs | nodejs | nodejs_crypto | 5x | 4 | var data = cipher.read();
if (data)
encrypted += data.toString('hex');
});
cipher.on('end', () => {
console.log(encrypted);
// Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504
});
cipher.write('some clear text data');
cipher.end();
```
Example: Using `Cipher` and piped streams:
``... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
77bff799-1708-5467-8106-a9d770498e30 | docs | nodejs | nodejs_crypto | 5x | 5 | // Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504
```
### cipher.final([output\_encoding])[#](#crypto_cipher_final_output_encoding)
Returns any remaining enciphered contents. If `output_encoding`
parameter is one of `'binary'`, `'base64'` or `'hex'`, a string is returned.
If an `output_enc... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
e27b490c-ee30-595a-8360-6a347a35cbef | docs | nodejs | nodejs_crypto | 5x | 6 | ### cipher.getAuthTag()[#](#crypto_cipher_getauthtag)
When using an authenticated encryption mode (only `GCM` is currently
supported), the `cipher.getAuthTag()` method returns a [`Buffer`](buffer.html) containing
the *authentication tag* that has been computed from the given data.
The `cipher.getAuthTag()` method sho... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6e1badd5-dbdb-5ebc-a76f-c0be2b5b2a15 | docs | nodejs | nodejs_crypto | 5x | 7 | Disabling automatic padding is useful for non-standard padding, for instance
using `0x0` instead of PKCS padding.
The `cipher.setAutoPadding()` method must be called before [`cipher.final()`](#crypto_cipher_final_output_encoding).
### cipher.update(data[, input\_encoding][, output\_encoding])[#](#crypto_cipher_update... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
f20e6b1c-de2a-5b37-8d0a-31659baa842f | docs | nodejs | nodejs_crypto | 5x | 8 | The `cipher.update()` method can be called multiple times with new data until
[`cipher.final()`](#crypto_cipher_final_output_encoding) is called. Calling `cipher.update()` after
[`cipher.final()`](#crypto_cipher_final_output_encoding) will result in an error being thrown.
## Class: Decipher[#](#crypto_class_decipher)
... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
894ae5ea-7cca-54e3-827c-7650139b83c4 | docs | nodejs | nodejs_crypto | 5x | 9 | used to create `Decipher` instances. `Decipher` objects are not to be created
directly using the `new` keyword.
Example: Using `Decipher` objects as streams:
```None
const crypto = require('crypto');
const decipher = crypto.createDecipher('aes192', 'a password');
var decrypted = '';
decipher.on('readable', () => {
... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
c04cf50a-8bd8-5627-b33f-07966110fba5 | docs | nodejs | nodejs_crypto | 5x | 10 | Example: Using the [`decipher.update()`](#crypto_decipher_update_data_input_encoding_output_encoding) and [`decipher.final()`](#crypto_decipher_final_output_encoding) methods:
```None
const crypto = require('crypto');
const decipher = crypto.createDecipher('aes192', 'a password');
var encrypted = 'ca981be48e908676045... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
0632e764-ffe1-5fe2-a6bb-9b8dc5b65b43 | docs | nodejs | nodejs_crypto | 5x | 11 | than once will result in an error being thrown.
### decipher.setAAD(buffer)[#](#crypto_decipher_setaad_buffer)
When using an authenticated encryption mode (only `GCM` is currently
supported), the `cipher.setAAD()` method sets the value used for the
*additional authenticated data* (AAD) input parameter.
### decipher.... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
8b24a228-5a64-54a8-81f0-f36aaa948b2a | docs | nodejs | nodejs_crypto | 5x | 12 | [`decipher.final()`](#crypto_decipher_final_output_encoding) from checking for and removing padding.
Turning auto padding off will only work if the input data's length is a
multiple of the ciphers block size.
The `decipher.setAutoPadding()` method must be called before
[`decipher.update()`](#crypto_decipher_update_da... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
d05801ec-0e63-5d02-aa41-cde975ddbd5d | docs | nodejs | nodejs_crypto | 5x | 13 | is specified, a string using the specified encoding is returned. If no
`output_encoding` is provided, a [`Buffer`](buffer.html) is returned.
The `decipher.update()` method can be called multiple times with new data until
[`decipher.final()`](#crypto_decipher_final_output_encoding) is called. Calling `decipher.update()... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
4643648a-3895-51a0-b18e-2d6d8d03d86a | docs | nodejs | nodejs_crypto | 5x | 14 | const bob = crypto.createDiffieHellman(alice.getPrime(), alice.getGenerator());
const bob_key = bob.generateKeys();
// Exchange and generate the secret...
const alice_secret = alice.computeSecret(bob_key);
const bob_secret = bob.computeSecret(alice_key);
// OK
assert.equal(alice_secret.toString('hex'), bob_secret.toS... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
0151525c-457a-5057-8feb-1243b5238c63 | docs | nodejs | nodejs_crypto | 5x | 15 | [`Buffer`](buffer.html) is returned.
### diffieHellman.generateKeys([encoding])[#](#crypto_diffiehellman_generatekeys_encoding)
Generates private and public Diffie-Hellman key values, and returns
the public key in the specified `encoding`. This key should be
transferred to the other party. Encoding can be `'binary'`,... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
f5568422-611d-586d-8c11-e2a7ad0e9432 | docs | nodejs | nodejs_crypto | 5x | 16 | returned; otherwise a [`Buffer`](buffer.html) is returned.
### diffieHellman.getPrivateKey([encoding])[#](#crypto_diffiehellman_getprivatekey_encoding)
Returns the Diffie-Hellman private key in the specified `encoding`,
which can be `'binary'`, `'hex'`, or `'base64'`. If `encoding` is provided a
string is returned; o... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
8fa3b38a-995e-5db1-b437-613d655b1aab | docs | nodejs | nodejs_crypto | 5x | 17 | to be a [`Buffer`](buffer.html).
### diffieHellman.setPublicKey(public\_key[, encoding])[#](#crypto_diffiehellman_setpublickey_public_key_encoding)
Sets the Diffie-Hellman public key. If the `encoding` argument is provided
and is either `'binary'`, `'hex'` or `'base64'`, `public_key` is expected
to be a string. If no... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
41477ca7-d170-5e49-a6c2-bb9860973a5a | docs | nodejs | nodejs_crypto | 5x | 18 | ## Class: ECDH[#](#crypto_class_ecdh)
The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
key exchanges.
Instances of the `ECDH` class can be created using the
[`crypto.createECDH()`](#crypto_crypto_createecdh_curve_name) function.
```None
const crypto = require('crypto');
const assert = ... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
826ce1e5-1b9f-51bb-ba1e-91134d820a8c | docs | nodejs | nodejs_crypto | 5x | 19 | party's public key and returns the computed shared secret. The supplied
key is interpreted using specified `input_encoding`, and the returned secret
is encoded using the specified `output_encoding`. Encodings can be
`'binary'`, `'hex'`, or `'base64'`. If the `input_encoding` is not
provided, `other_public_key` is expec... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
bde18e08-4b1b-5f09-af4e-ac3e71268f31 | docs | nodejs | nodejs_crypto | 5x | 20 | `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html)
is returned.
### ecdh.getPrivateKey([encoding])[#](#crypto_ecdh_getprivatekey_encoding)
Returns the EC Diffie-Hellman private key in the specified `encoding`,
which can be `'binary'`, `'hex'`, or `'base64'`. If `encoding` is provided
a s... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
0bb5d72b-63d8-56a7-a6e8-18c34c744e19 | docs | nodejs | nodejs_crypto | 5x | 21 | ### ecdh.setPrivateKey(private\_key[, encoding])[#](#crypto_ecdh_setprivatekey_private_key_encoding)
Sets the EC Diffie-Hellman private key. The `encoding` can be `'binary'`,
`'hex'` or `'base64'`. If `encoding` is provided, `private_key` is expected
to be a string; otherwise `private_key` is expected to be a [`Buffer... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
625c7d77-44db-5563-aff3-e3c959b75841 | docs | nodejs | nodejs_crypto | 5x | 22 | only requires a private key and the other party's public key to compute the
shared secret. Typically either [`ecdh.generateKeys()`](#crypto_ecdh_generatekeys_encoding_format) or
[`ecdh.setPrivateKey()`](#crypto_ecdh_setprivatekey_private_key_encoding) will be called. The [`ecdh.setPrivateKey()`](#crypto_ecdh_setprivate... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
a89b8dba-26d2-5800-9ee3-c5a943f4cb3c | docs | nodejs | nodejs_crypto | 5x | 23 | const alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
const bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
// alice_secret and bob_secret should be the same shared secret value
console.log(alice_secret === bob_secret);
```
## Class: Hash[#](#crypto_class_hash)
The `Hash` clas... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
634cba96-dff7-54c5-8555-24ec4af0efd4 | docs | nodejs | nodejs_crypto | 5x | 24 |
hash.on('readable', () => {
var data = hash.read();
if (data)
console.log(data.toString('hex'));
// Prints:
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
});
hash.write('some data to hash');
hash.end();
```
Example: Using `Hash` and piped streams:
```None
const crypto = requi... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
2c8b82b7-ebc6-5ce9-8ab0-d08a91530ab8 | docs | nodejs | nodejs_crypto | 5x | 25 | ### hash.digest([encoding])[#](#crypto_hash_digest_encoding)
Calculates the digest of all of the data passed to be hashed (using the
[`hash.update()`](#crypto_hash_update_data_input_encoding) method). The `encoding` can be `'hex'`, `'binary'` or
`'base64'`. If `encoding` is provided a string will be returned; otherwis... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
995c5ee3-bd00-5dca-b150-3840871a928a | docs | nodejs | nodejs_crypto | 5x | 26 | ## Class: Hmac[#](#crypto_class_hmac)
The `Hmac` Class is a utility for creating cryptographic HMAC digests. It can
be used in one of two ways:
* As a [stream](stream.html) that is both readable and writable, where data is written
to produce a computed HMAC digest on the readable side, or
* Using the [`hmac.update(... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6bc0d2ab-1a21-5858-96d9-54eaa19af882 | docs | nodejs | nodejs_crypto | 5x | 27 | hmac.end();
```
Example: Using `Hmac` and piped streams:
```None
const crypto = require('crypto');
const fs = require('fs');
const hmac = crypto.createHmac('sha256', 'a secret');
const input = fs.createReadStream('test.js');
input.pipe(hmac).pipe(process.stdout);
```
Example: Using the [`hmac.update()`](#crypto_hma... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
341ab8e8-f414-53b2-b26f-7b812efac3d5 | docs | nodejs | nodejs_crypto | 5x | 28 | The `Hmac` object can not be used again after `hmac.digest()` has been
called. Multiple calls to `hmac.digest()` will result in an error being thrown.
### hmac.update(data[, input\_encoding])[#](#crypto_hmac_update_data_input_encoding)
Updates the `Hmac` content with the given `data`, the encoding of which
is given i... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
7325d526-4343-527c-812c-2bedd93b90a3 | docs | nodejs | nodejs_crypto | 5x | 29 | * Using the [`sign.update()`](#crypto_sign_update_data_input_encoding) and [`sign.sign()`](#crypto_sign_sign_private_key_output_format) methods to produce the
signature.
The [`crypto.createSign()`](#crypto_crypto_createsign_algorithm) method is used to create `Sign` instances. `Sign`
objects are not to be created di... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
e36f0b96-8e4a-5090-9b9a-aae0ff3ddb08 | docs | nodejs | nodejs_crypto | 5x | 30 | console.log(sign.sign(private_key, 'hex'));
// Prints the calculated signature
```
A [`sign`][] instance can also be created by just passing in the digest
algorithm name, in which case OpenSSL will infer the full signature algorithm
from the type of the PEM-formatted private key, including algorithms that
do not hav... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
3911bd87-e222-5cdb-9174-db67a083a29b | docs | nodejs | nodejs_crypto | 5x | 31 | ### sign.sign(private\_key[, output\_format])[#](#crypto_sign_sign_private_key_output_format)
Calculates the signature on all the data passed through using either
[`sign.update()`](#crypto_sign_update_data_input_encoding) or [`sign.write()`](stream.html#stream_writable_write_chunk_encoding_callback).
The `private_key... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
a62990bb-083c-503d-abab-08d1745bd457 | docs | nodejs | nodejs_crypto | 5x | 32 | The `Sign` object can not be again used after `sign.sign()` method has been
called. Multiple calls to `sign.sign()` will result in an error being thrown.
### sign.update(data[, input\_encoding])[#](#crypto_sign_update_data_input_encoding)
Updates the `Sign` content with the given `data`, the encoding of which
is give... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6b81d4b7-a2c6-5d36-abe7-cf76778b94bf | docs | nodejs | nodejs_crypto | 5x | 33 | * Using the [`verify.update()`](#crypto_verifier_update_data_input_encoding) and [`verify.verify()`](#crypto_verifier_verify_object_signature_signature_format) methods to verify
the signature.
The [`crypto.createSign()`](#crypto_crypto_createsign_algorithm) method is used to create `Sign` instances.
`Sign` objec... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
74977ebf-c846-5082-a164-a3b0aa4bcd13 | docs | nodejs | nodejs_crypto | 5x | 34 | verify.update('some data to sign');
const public_key = getPublicKeySomehow();
const signature = getSignatureToVerify();
console.log(verify.verify(public_key, signature));
// Prints true or false
```
### verifier.update(data[, input\_encoding])[#](#crypto_verifier_update_data_input_encoding)
Updates the `Verify` co... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
740d1cb1-75be-5abb-9122-218be4525e02 | docs | nodejs | nodejs_crypto | 5x | 35 | The `signature` argument is the previously calculated signature for the data, in
the `signature_format` which can be `'binary'`, `'hex'` or `'base64'`.
If a `signature_format` is specified, the `signature` is expected to be a
string; otherwise `signature` is expected to be a [`Buffer`](buffer.html).
Returns `true` or ... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
aac2fcf0-37b4-586e-b474-69eec7da39b9 | docs | nodejs | nodejs_crypto | 5x | 36 | with legacy programs that expect `'binary'` to be the default encoding.
New applications should expect the default to be `'buffer'`. This property may
become deprecated in a future Node.js release.
### crypto.createCipher(algorithm, password)[#](#crypto_crypto_createcipher_algorithm_password)
Creates and returns a `... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
aca285b0-6d94-5002-a216-4a3d3bf71e67 | docs | nodejs | nodejs_crypto | 5x | 37 | password always creates the same key. The low iteration count and
non-cryptographically secure hash algorithm allow passwords to be tested very
rapidly.
In line with OpenSSL's recommendation to use pbkdf2 instead of
[`EVP_BytesToKey`](https://www.openssl.org/docs/crypto/EVP_BytesToKey.html) it is recommended that deve... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
57fdf7d5-d4a8-50f5-9291-20f2d146b726 | docs | nodejs | nodejs_crypto | 5x | 38 | [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'binary'` encoded strings or
[buffers](buffer.html).
### crypto.createCredentials(details)[#](#crypto_crypto_createcredentials_details)
```None
Stability: 0 - Deprecated: Use tls.createSecureContext() instead.
```
T... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
e1c04712-7776-56ac-ab72-dfe43c010090 | docs | nodejs | nodejs_crypto | 5x | 39 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - passphrase for the private key or PFX
* `cert` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded certificate
* `ca` : [<String>](https://develo... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
1cf8afba-fabf-59f0-b27a-fbcb66ca95e2 | docs | nodejs | nodejs_crypto | 5x | 40 | * `ciphers`: [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) using the [OpenSSL cipher list format](https://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) describing the
cipher algorithms to use or exclude.
If no 'ca' details are given, Node.js will use Moz... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6c2feb54-b73a-526a-8724-08377c6157b5 | docs | nodejs | nodejs_crypto | 5x | 41 | non-cryptographically secure hash algorithm allow passwords to be tested very
rapidly.
In line with OpenSSL's recommendation to use pbkdf2 instead of
[`EVP_BytesToKey`](https://www.openssl.org/docs/crypto/EVP_BytesToKey.html) it is recommended that developers derive a key and IV on
their own using [`crypto.pbkdf2()`](... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
9227ac97-6031-5493-af1d-72c38a67f992 | docs | nodejs | nodejs_crypto | 5x | 42 | [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'binary'` encoded strings or
[buffers](buffer.html).
### crypto.createDiffieHellman(prime[, prime\_encoding][, generator][, generator\_encoding])[#](#crypto_crypto_creatediffiehellman_prime_prime_encoding_generator_ge... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
4c66812b-49bd-5b44-82c5-49d72f99e6db | docs | nodejs | nodejs_crypto | 5x | 43 | ### crypto.createDiffieHellman(prime\_length[, generator])[#](#crypto_crypto_creatediffiehellman_prime_length_generator)
Creates a `DiffieHellman` key exchange object and generates a prime of
`prime_length` bits using an optional specific numeric `generator`.
If `generator` is not specified, the value `2` is used.
##... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
171b1a2b-8c77-5b0a-bfe6-ef35ecf81500 | docs | nodejs | nodejs_crypto | 5x | 44 | version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
On recent releases of OpenSSL, `openssl list-message-digest-algorithms` will
display the available digest algorithms.
Example: generating the sha256 sum of a file
```None
const filename = process.argv[2];
const crypto = require('crypto');
c... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
ff8675c1-1738-5758-a6d4-067231b2f066 | docs | nodejs | nodejs_crypto | 5x | 45 | display the available digest algorithms.
The `key` is the HMAC key used to generate the cryptographic HMAC hash.
Example: generating the sha256 HMAC of a file
```None
const filename = process.argv[2];
const crypto = require('crypto');
const fs = require('fs');
const hmac = crypto.createHmac('sha256', 'a secret');
... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
efbb30eb-68b8-5d20-86f5-d187bff26ae3 | docs | nodejs | nodejs_crypto | 5x | 46 | ### crypto.createVerify(algorithm)[#](#crypto_crypto_createverify_algorithm)
Creates and returns a `Verify` object that uses the given algorithm. On
recent OpenSSL releases, `openssl list-public-key-algorithms` will
display the available signing algorithms. One example is `'RSA-SHA256'`.
### crypto.getCiphers()[#](#c... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
ed49f66a-836a-5b17-9508-bffd572fe853 | docs | nodejs | nodejs_crypto | 5x | 47 | [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see [Caveats](#crypto_support_for_weak_or_compromised_algorithms)) and `'modp14'`, `'modp15'`,
`'modp16'`, `'modp17'`, `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The
returned object mimics the interface of objects created b... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
2fe34dc1-3257-5f81-8b66-4ee14ae44bc6 | docs | nodejs | nodejs_crypto | 5x | 48 | const alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
const bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
/* alice_secret and bob_secret should be the same */
console.log(alice_secret == bob_secret);
```
### crypto.getHashes()[#](#crypto_crypto_gethashes)
Returns an array wi... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6fba9872-9405-5601-84d5-1df88c51a101 | docs | nodejs | nodejs_crypto | 5x | 49 | The supplied `callback` function is called with two arguments: `err` and
`derivedKey`. If an error occurs, `err` will be set; otherwise `err` will be
null. The successfully generated `derivedKey` will be passed as a [`Buffer`](buffer.html).
The `iterations` argument must be a number set as high as possible. The
higher... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
43c08456-6152-521c-bdac-2586459a8109 | docs | nodejs | nodejs_crypto | 5x | 50 | ### crypto.pbkdf2Sync(password, salt, iterations, keylen[, digest])[#](#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest)
Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
implementation. A selected HMAC digest algorithm specified by `digest` is
applied to derive a key of the requ... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
f07fa924-40e1-51f6-b071-e33cb0ac4cce | docs | nodejs | nodejs_crypto | 5x | 51 | [NIST SP 800-132](http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf) for details.
Example:
```None
const crypto = require('crypto');
const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512');
console.log(key.toString('hex')); // 'c5e478d...1469e50'
```
An array of supported digest f... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
6b98cf66-1ebd-5485-ac73-80cc24ea6fe8 | docs | nodejs | nodejs_crypto | 5x | 52 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - Optional passphrase for the private key
* `padding` : An optional padding value, one of the following:
+ `constants.RSA_NO_PADDING`
+ `constants.RSA_PKCS1_PADDING`
+ `constants.RSA_PKCS1_OAEP_PADDING... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
f2545324-cec5-50fd-94ea-c0f352c49498 | docs | nodejs | nodejs_crypto | 5x | 53 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - Optional passphrase for the private key
* `padding` : An optional padding value, one of the following:
+ `constants.RSA_NO_PADDING`
+ `constants.RSA_PKCS1_PADDING`
+ `constants.RSA_PKCS1_OAEP_PADDING... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
b3531653-4c5e-53a2-8529-6ccfa8be78ad | docs | nodejs | nodejs_crypto | 5x | 54 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - Optional passphrase for the private key
* `padding` : An optional padding value, one of the following:
+ `constants.RSA_NO_PADDING`
+ `constants.RSA_PKCS1_PADDING`
+ `constants.RSA_PKCS1_OAEP_PADDING... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
e987ed66-46d2-516b-815c-172d14300982 | docs | nodejs | nodejs_crypto | 5x | 55 | * `passphrase` : [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - Optional passphrase for the private key
* `padding` : An optional padding value, one of the following:
+ `constants.RSA_NO_PADDING`
+ `constants.RSA_PKCS1_PADDING`
+ `constants.RSA_PKCS1_OAEP_PADDING... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
549f7952-ddb5-5900-87e8-4b4b0827af5f | docs | nodejs | nodejs_crypto | 5x | 56 | // Asynchronous
const crypto = require('crypto');
crypto.randomBytes(256, (err, buf) => {
if (err) throw err;
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
});
```
If the `callback` function is not provided, the random bytes are generated
synchronously and returned as a [`Buffer`](buff... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
2b23d982-0ebf-505e-a594-4a768602a04b | docs | nodejs | nodejs_crypto | 5x | 57 | ### crypto.setEngine(engine[, flags])[#](#crypto_crypto_setengine_engine_flags)
Load and set the `engine` for some or all OpenSSL functions (selected by flags).
`engine` could be either an id or a path to the engine's shared library.
The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`
is a... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
a88f0193-c804-5590-8489-15dfbccfe83a | docs | nodejs | nodejs_crypto | 5x | 58 | 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 `'binary'` encoded strings by default rather than Buffers. This
def... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
5e60b9c3-addd-5f28-bf4f-811998632fbf | docs | nodejs | nodejs_crypto | 5x | 59 | The [`ecdh.setPublicKey()`](#crypto_ecdh_setpublickey_public_key_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_form... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
aba51fc3-b158-5172-a1fb-b7eae170f286 | docs | nodejs | nodejs_crypto | 5x | 60 | Based on the recommendations of [NIST SP 800-131A](http://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 least... | large_dataset/raw/docs/nodejs/crypto/crypto_5x.md |
c775f42d-47c8-5d16-8597-96942a3cea75 | docs | nodejs | nodejs_crypto | 6x | 0 | # Crypto#
Source: https://nodejs.org/docs/latest-v6.x/api/crypto.html
Version: 6.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 functions.
... | large_dataset/raw/docs/nodejs/crypto/crypto_6x.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.