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
fa5d9310-aff4-51cb-9021-81545e5a1659
docs
nodejs
nodejs_crypto
6x
1
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 now specified formally as part of [HTML5's `keygen` element](http://www.w3.org/TR/html5/forms.html#the-keyg...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
582cc8a7-a4a3-5a1f-8e9d-6308991afdfb
docs
nodejs
nodejs_crypto
6x
2
### certificate.exportChallenge(spkac)[#](#crypto_certificate_exportchallenge_spkac) Added in: v0.11.8 The `spkac` data structure includes a public key and a challenge. The `certificate.exportChallenge()` returns the challenge component in the form of a Node.js [`Buffer`](buffer.html). The `spkac` argument can be eit...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0ecb7948-48b5-502c-90cc-0a9faa8144f5
docs
nodejs
nodejs_crypto
6x
3
const spkac = getSpkacSomehow(); const publicKey = cert.exportPublicKey(spkac); console.log(publicKey); // Prints: the public key as <Buffer ...> ``` ### certificate.verifySpkac(spkac)[#](#crypto_certificate_verifyspkac_spkac) Added in: v0.11.8 Returns `true` if the given `spkac` data structure is valid, `false` oth...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0b919a24-9c98-5fbe-8ae4-1c0b6b2716bd
docs
nodejs
nodejs_crypto
6x
4
* Using the [`cipher.update()`](#crypto_cipher_update_data_input_encoding_output_encoding) and [`cipher.final()`](#crypto_cipher_final_output_encoding) methods to produce the encrypted data. The [`crypto.createCipher()`](#crypto_crypto_createcipher_algorithm_password) or [`crypto.createCipheriv()`](#crypto_crypto_cr...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
37fe549d-3520-5e43-8091-161735c55689
docs
nodejs
nodejs_crypto
6x
5
const crypto = require('crypto'); const fs = require('fs'); const cipher = crypto.createCipher('aes192', 'a password'); const input = fs.createReadStream('test.js'); const output = fs.createWriteStream('test.enc'); input.pipe(cipher).pipe(output); ``` Example: Using the [`cipher.update()`](#crypto_cipher_update_data...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
993e9e59-7f4a-5d8b-a354-a3244a1225d6
docs
nodejs
nodejs_crypto
6x
6
If an `output_encoding` is not provided, a [`Buffer`](buffer.html) is returned. Once the `cipher.final()` method has been called, the `Cipher` object can no longer be used to encrypt data. Attempts to call `cipher.final()` more than once will result in an error being thrown. ### cipher.setAAD(buffer)[#](#crypto_ciphe...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
eb648c15-0b70-5358-9e8e-acb079bcd735
docs
nodejs
nodejs_crypto
6x
7
been completed using the [`cipher.final()`](#crypto_cipher_final_output_encoding) method. ### cipher.setAutoPadding(auto\_padding=true)[#](#crypto_cipher_setautopadding_auto_padding_true) Added in: v0.7.1 When using block encryption algorithms, the `Cipher` class will automatically add padding to the input data to t...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
23985205-d842-5c0d-84f9-433967a027e3
docs
nodejs
nodejs_crypto
6x
8
### cipher.update(data[, input\_encoding][, output\_encoding])[#](#crypto_cipher_update_data_input_encoding_output_encoding) Added in: v0.1.94 Updates the cipher with `data`. If the `input_encoding` argument is given, its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` argument is a string usin...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
f8c9d1f9-8e8b-55d6-a438-123682485f08
docs
nodejs
nodejs_crypto
6x
9
[`cipher.final()`](#crypto_cipher_final_output_encoding) will result in an error being thrown. ## Class: Decipher[#](#crypto_class_decipher) Added in: v0.1.94 Instances of the `Decipher` class are used to decrypt data. The class can be used in one of two ways: * As a [stream](stream.html) that is both readable and ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
72fad80c-42d0-5a06-bc66-d4a26979c642
docs
nodejs
nodejs_crypto
6x
10
const decipher = crypto.createDecipher('aes192', 'a password'); let decrypted = ''; decipher.on('readable', () => { const data = decipher.read(); if (data) decrypted += data.toString('utf8'); }); decipher.on('end', () => { console.log(decrypted); // Prints: some clear text data }); const encrypted = 'ca...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
e1c89099-d952-53bb-b691-a71e4805ff32
docs
nodejs
nodejs_crypto
6x
11
const decipher = crypto.createDecipher('aes192', 'a password'); const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); // Prints: some clear text data ``` ### deciph...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
481ebca0-d531-5cd3-91cb-14510f542ecc
docs
nodejs
nodejs_crypto
6x
12
### decipher.setAAD(buffer)[#](#crypto_decipher_setaad_buffer) Added in: v1.0.0 When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAAD()` method sets the value used for the *additional authenticated data* (AAD) input parameter. Returns `this` for method chaining. ### d...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
f5296359-046f-5b73-96e0-4a86c334ed9c
docs
nodejs
nodejs_crypto
6x
13
### decipher.setAutoPadding(auto\_padding=true)[#](#crypto_decipher_setautopadding_auto_padding_true) Added in: v0.7.1 When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent [`decipher.final()`](#crypto_decipher_final_output_enco...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
90eb6f48-afce-526f-b328-dfd7f2858922
docs
nodejs
nodejs_crypto
6x
14
argument is a string using the specified encoding. If the `input_encoding` argument is not given, `data` must be a [`Buffer`](buffer.html). If `data` is a [`Buffer`](buffer.html) then `input_encoding` is ignored. The `output_encoding` specifies the output format of the enciphered data, and can be `'latin1'`, `'ascii'`...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
82fb3861-13dc-56dd-bc88-646beb03c2bc
docs
nodejs
nodejs_crypto
6x
15
[`crypto.createDiffieHellman()`](#crypto_crypto_creatediffiehellman_prime_prime_encoding_generator_generator_encoding) function. ```None const crypto = require('crypto'); const assert = require('assert'); // Generate Alice's keys... const alice = crypto.createDiffieHellman(2048); const aliceKey = alice.generateKeys()...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
661b56f8-daaa-53bb-8c2f-d9ba29c11192
docs
nodejs
nodejs_crypto
6x
16
key is interpreted using the specified `input_encoding`, and secret is encoded using specified `output_encoding`. Encodings can be `'latin1'`, `'hex'`, or `'base64'`. If the `input_encoding` is not provided, `other_public_key` is expected to be a [`Buffer`](buffer.html). If `output_encoding` is given a string is retur...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
375553b5-c294-5635-a21b-950d5e88b16f
docs
nodejs
nodejs_crypto
6x
17
be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html) is returned. ### diffieHellman.getPrime([encoding])[#](#crypto_diffiehellman_getprime_encoding) Added in: v0.5.0 Returns the Diffie-Hellman prime in the specified `encoding`, which can be `'lati...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c4fd18a6-9a70-580d-bd71-8430c11bd34c
docs
nodejs
nodejs_crypto
6x
18
can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html) is returned. ### diffieHellman.setPrivateKey(private\_key[, encoding])[#](#crypto_diffiehellman_setprivatekey_private_key_encoding) Added in: v0.5.0 Sets the Diffie-Hellman private key. If t...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
69e59179-444b-538e-bbc2-f9573381f382
docs
nodejs
nodejs_crypto
6x
19
### 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_6x.md
342d0c1c-39d0-5917-a8cf-e9660502c43f
docs
nodejs
nodejs_crypto
6x
20
// Exchange and generate the secret... const aliceSecret = alice.computeSecret(bobKey); const bobSecret = bob.computeSecret(aliceKey); assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); // OK ``` ### ecdh.computeSecret(other\_public\_key[, input\_encoding][, output\_encoding])[#](#crypto_ecdh...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0f2d8ad8-1367-596c-a0b1-d71eacd3106b
docs
nodejs
nodejs_crypto
6x
21
### ecdh.generateKeys([encoding[, format]])[#](#crypto_ecdh_generatekeys_encoding_format) Added in: v0.11.14 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` arguments specif...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
ef47d931-121b-5e5b-85a6-c6c9ae36d2a0
docs
nodejs
nodejs_crypto
6x
22
### ecdh.getPublicKey([encoding[, format]])[#](#crypto_ecdh_getpublickey_encoding_format) Added in: v0.11.14 Returns the EC Diffie-Hellman public key in the specified `encoding` and `format`. The `format` argument specifies point encoding and can be `'compressed'`, `'uncompressed'`, or `'hybrid'`. If `format` is not...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
596d9cce-5a43-55f7-9ac9-a6ef4f1b5c83
docs
nodejs
nodejs_crypto
6x
23
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(public\_key[, encoding])[#](#crypto_ecdh_setpublickey_public_key_encoding) Added in: v0.11.14 Deprecated since: v5.2.0 [Stability: 0](documentation.html#doc...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c7e065a7-7f62-572a-a299-e145c06eb97c
docs
nodejs
nodejs_crypto
6x
24
attempts to generate the public point/key associated with the private key being set. Example (obtaining a shared secret): ```None const crypto = require('crypto'); const alice = crypto.createECDH('secp256k1'); const bob = crypto.createECDH('secp256k1'); // Note: This is a shortcut way to specify one of Alice's previ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
726809fd-207e-587b-a56e-cfd40e342b9a
docs
nodejs
nodejs_crypto
6x
25
## Class: Hash[#](#crypto_class_hash) Added in: v0.1.92 The `Hash` class is a utility for creating hash digests of data. 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 hash digest on the readable side, or * Using the [...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
6f19c8a8-a3fb-5969-80fd-dd7f55338b74
docs
nodejs
nodejs_crypto
6x
26
hash.end(); ``` 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_dat...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
dd39a048-ed7f-5a19-a491-dffe2eaa9f93
docs
nodejs
nodejs_crypto
6x
27
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_6x.md
7c6723cd-cf8c-5807-b2b3-8c561b1065ee
docs
nodejs
nodejs_crypto
6x
28
* Using the [`hmac.update()`](#crypto_hmac_update_data_input_encoding) 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 ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
75997cf8-982d-53e1-82f4-abc5588dade7
docs
nodejs
nodejs_crypto
6x
29
Example: Using the [`hmac.update()`](#crypto_hmac_update_data_input_encoding) 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: // ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
feee1566-fab6-5e53-8068-1dc97be29118
docs
nodejs
nodejs_crypto
6x
30
### 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 `'latin1'`. If `encoding` is not provided, and the `data` is a string, an encodi...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0d96bcda-bda6-5367-832b-1546dc2078de
docs
nodejs
nodejs_crypto
6x
31
The [`crypto.createSign()`](#crypto_crypto_createsign_algorithm) method is used to create `Sign` instances. The argument is the string name of the hash function to use. `Sign` objects are not to be created directly using the `new` keyword. Example: Using `Sign` objects as streams: ```None const crypto = require('cryp...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0cacdab8-0f24-5ceb-9a59-e9f2757efc0a
docs
nodejs
nodejs_crypto
6x
32
const privateKey = getPrivateKeySomehow(); console.log(sign.sign(privateKey, 'hex')); // Prints: the calculated signature ``` In some cases, a `Sign` instance can also be created by passing in a signature algorithm name, such as 'RSA-SHA256'. This will use the corresponding digest algorithm. This does not work for all...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
76f2427a-d1cd-50f2-8a08-c5bd6ec48080
docs
nodejs
nodejs_crypto
6x
33
[`sign.update()`](#crypto_sign_update_data_input_encoding) 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 must contain...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
e281a2e0-18e8-5bce-ac5e-02e20f47378e
docs
nodejs
nodejs_crypto
6x
34
used to sign the message as specified in section 3.1 of [RFC 4055](https://www.rfc-editor.org/rfc/rfc4055.txt). * `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.cons...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
74bd05a1-c6e9-5d39-98b0-8676da51404b
docs
nodejs
nodejs_crypto
6x
35
### 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 `'latin1'`. If `encoding` is not provided, and the `data` is a string, an encodi...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
8f406f7e-697f-5073-8600-a77cf674a224
docs
nodejs
nodejs_crypto
6x
36
The [`crypto.createVerify()`](#crypto_crypto_createverify_algorithm) method is used to create `Verify` instances. `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('SHA256');...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
43777fa3-cbac-594e-ab04-618df4c35019
docs
nodejs
nodejs_crypto
6x
37
### 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 `'latin1'`. If `encoding` is not provided, and the `data` is a string,...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
00467a9e-514c-57ee-9060-d8eda3b7b8b3
docs
nodejs
nodejs_crypto
6x
38
* `signature` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<Uint8Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) * `signature_format` [<string>](https://developer.mozi...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c08334cd-6bf5-593a-bb1f-ca746fec9a8d
docs
nodejs
nodejs_crypto
6x
39
+ `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>](https://developer.mozilla.org/en-US/docs/Web/JavaScr...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c82e3e5b-8d0b-52b2-bb25-90f00d3dcc16
docs
nodejs
nodejs_crypto
6x
40
The `verifier` 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_6x.md
e0548f1b-c847-5c7a-b842-f4a014980582
docs
nodejs
nodejs_crypto
6x
41
New applications should expect the default to be `'buffer'`. This property may become deprecated in a future Node.js release. ### crypto.fips[#](#crypto_crypto_fips) Added in: v6.0.0 Property for checking and controlling whether a FIPS compliant crypto provider is currently in use. Setting to true requires a FIPS bu...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
2e9c0a84-e8a8-5cc4-8be6-440137f0e428
docs
nodejs
nodejs_crypto
6x
42
function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.0.2/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 the same key. The low iteration count and non-cryptographically secure hash algor...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
8e2684f9-f241-5d3b-b509-407202c7d6ac
docs
nodejs
nodejs_crypto
6x
43
vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details. ### crypto.createCipheriv(algorithm, key, iv)[#](#crypto_crypto_createcipheriv_algorithm_key_iv) Creates and returns a `Cipher` object, with the given `algor...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
f7550ef1-52a5-5c86-a1a2-c3006cc6ec98
docs
nodejs
nodejs_crypto
6x
44
[Stability: 0](documentation.html#documentation_stability_index) - Deprecated: Use [`tls.createSecureContext()`](tls.html#tls_tls_createsecurecontext_options) instead. * `details` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) Identical to [`tls.createSecureContext(...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
ba2ce26d-3452-5566-86a5-f1ee1b903f21
docs
nodejs
nodejs_crypto
6x
45
The implementation of `crypto.createDecipher()` derives keys using the OpenSSL function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.0.2/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_6x.md
4769ea7c-fcd7-58aa-b96d-e7e2bb9316f2
docs
nodejs
nodejs_crypto
6x
46
### crypto.createDecipheriv(algorithm, key, iv)[#](#crypto_crypto_createdecipheriv_algorithm_key_iv) Added in: v0.1.94 Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`). The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On recent Open...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
aa306a84-d510-535e-b707-0f200053d7cb
docs
nodejs
nodejs_crypto
6x
47
The `generator` argument can be a number, string, or [`Buffer`](buffer.html). If `generator` is not specified, the value `2` is used. The `prime_encoding` and `generator_encoding` arguments can be `'latin1'`, `'hex'`, or `'base64'`. If `prime_encoding` is specified, `prime` is expected to be a string; otherwise a [`B...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
8c18c56b-a467-535a-b1e9-e69db504a939
docs
nodejs
nodejs_crypto
6x
48
### crypto.createECDH(curve\_name)[#](#crypto_crypto_createecdh_curve_name) Added in: v0.11.14 Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a predefined curve specified by the `curve_name` string. Use [`crypto.getCurves()`](#crypto_crypto_getcurves) to obtain a list of available curve n...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
b876d401-55cd-5080-bdc4-bb97183e6968
docs
nodejs
nodejs_crypto
6x
49
const crypto = require('crypto'); const fs = require('fs'); const hash = crypto.createHash('sha256'); const input = fs.createReadStream(filename); input.on('readable', () => { const data = input.read(); if (data) hash.update(data); else { console.log(`${hash.digest('hex')} ${filename}`); } }); ``` ##...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
fac752bc-20ed-55e9-891f-1e51814b6865
docs
nodejs
nodejs_crypto
6x
50
const hmac = crypto.createHmac('sha256', 'a secret'); const input = fs.createReadStream(filename); input.on('readable', () => { const data = input.read(); if (data) hmac.update(data); else { console.log(`${hmac.digest('hex')} ${filename}`); } }); ``` ### crypto.createSign(algorithm)[#](#crypto_crypto_...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
ea041172-1095-5f0c-9e21-cc97318d35d7
docs
nodejs
nodejs_crypto
6x
51
### crypto.getCiphers()[#](#crypto_crypto_getciphers) Added in: v0.9.3 Returns an array with the names of the supported cipher algorithms. Example: ```None const ciphers = crypto.getCiphers(); console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...] ``` ### crypto.getCurves()[#](#crypto_crypto_getcurves) Adde...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
6cd1bd53-8da8-59d4-b9f4-ddb405b0dac9
docs
nodejs
nodejs_crypto
6x
52
returned object mimics the interface of objects created by [`crypto.createDiffieHellman()`](#crypto_crypto_creatediffiehellman_prime_prime_encoding_generator_generator_encoding), but will not allow changing the keys (with [`diffieHellman.setPublicKey()`](#crypto_diffiehellman_setpublickey_public_key_encoding) for examp...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
15372a4c-8068-50df-b9be-df4f3f4e332e
docs
nodejs
nodejs_crypto
6x
53
### crypto.getHashes()[#](#crypto_crypto_gethashes) Added in: v0.9.3 Returns an array of the names of the supported hash algorithms, such as `RSA-SHA256`. Example: ```None const hashes = crypto.getHashes(); console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] ``` ### crypto.pbkdf2(password, salt, iterations...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
894a7ad5-9493-59bd-9a48-7b5ca8b62815
docs
nodejs
nodejs_crypto
6x
54
higher the number of iterations, the more secure the derived key will be, but will take a longer amount of time to complete. The `salt` should also be as unique as possible. It is recommended that the salts are random and their lengths are at least 16 bytes. See [NIST SP 800-132](http://nvlpubs.nist.gov/nistpubs/Legac...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
dd9b45c2-05d8-5ad5-bdb0-9d5e4b9aaf09
docs
nodejs
nodejs_crypto
6x
55
applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`. 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 o...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
a903be83-048d-5b7a-9cb7-9434bc7cb2e0
docs
nodejs
nodejs_crypto
6x
56
### 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_6x.md
78362235-58a9-5345-8491-20cdda71cf36
docs
nodejs
nodejs_crypto
6x
57
### crypto.timingSafeEqual(a, b)[#](#crypto_crypto_timingsafeequal_a_b) Added in: v6.6.0 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 comparing HMAC digests or ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
f31a4da7-2548-589c-aa49-67cef6a28ee8
docs
nodejs
nodejs_crypto
6x
58
If `private_key` is an object, it is interpreted as a hash object with the keys: * `key`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded private key * `passphrase`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_t...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
33c0f5ee-ef2d-5397-bacd-a51ae1b60acc
docs
nodejs
nodejs_crypto
6x
59
* `key`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded public key * `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 va...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
1bc85c10-a774-5511-97a3-8631f9b6a7c1
docs
nodejs
nodejs_crypto
6x
60
* `key`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - PEM encoded public key * `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 v...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
76f63d97-5493-5d23-84d2-461b6683197f
docs
nodejs
nodejs_crypto
6x
61
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 // Asynchronous const crypto = require('crypto'); crypto.randomBytes(256, (err, buf) => { if (err) throw err; console.log(`${buf.length} bytes of random d...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c08c8662-45b2-5339-b645-ac7591f4e2f3
docs
nodejs
nodejs_crypto
6x
62
time is right after boot, when the whole system is still low on entropy. ### crypto.randomFillSync(buffer[, offset][, size])[#](#crypto_crypto_randomfillsync_buffer_offset_size) Added in: v6.13.0 * `buffer` [<Buffer>](buffer.html#buffer_class_buffer) | [<Uint8Array>](https://developer.mozilla.org/en-US/docs/Web/Java...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
c6cfab62-9ebe-543d-b7e6-1adbd338967a
docs
nodejs
nodejs_crypto
6x
63
console.log(buf.toString('hex')); ``` ### crypto.randomFill(buffer[, offset][, size], callback)[#](#crypto_crypto_randomfill_buffer_offset_size_callback) Added in: v6.13.0 * `buffer` [<Buffer>](buffer.html#buffer_class_buffer) | [<Uint8Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
41904f8b-1c25-544d-a2d3-6a4533900b16
docs
nodejs
nodejs_crypto
6x
64
If the `callback` function is not provided, an error will be thrown. ```None const buf = Buffer.alloc(10); crypto.randomFill(buf, (err, buf) => { if (err) throw err; console.log(buf.toString('hex')); }); crypto.randomFill(buf, 5, (err, buf) => { if (err) throw err; console.log(buf.toString('hex')); }); // Th...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
8d8ac409-a23e-529c-90df-dfff49fce982
docs
nodejs
nodejs_crypto
6x
65
* `crypto.constants.ENGINE_METHOD_RAND` * `crypto.constants.ENGINE_METHOD_ECDH` * `crypto.constants.ENGINE_METHOD_ECDSA` * `crypto.constants.ENGINE_METHOD_CIPHERS` * `crypto.constants.ENGINE_METHOD_DIGESTS` * `crypto.constants.ENGINE_METHOD_STORE` * `crypto.constants.ENGINE_METHOD_PKEY_METHS` * `crypto.constants.ENGINE...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
bde8cf3b-ed05-5e1c-938e-3d63d29bdb49
docs
nodejs
nodejs_crypto
6x
66
default was changed after Node.js v0.8 to use [`Buffer`](buffer.html) objects by default instead. ### 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 ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
497f7d28-bb9c-59fa-99dc-288f8c35284d
docs
nodejs
nodejs_crypto
6x
67
should be called. The main drawback of using [`ecdh.setPublicKey()`](#crypto_ecdh_setpublickey_public_key_encoding) is that 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 stil...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
61a3d366-7cf4-5a7b-813b-20cfcc4c3b39
docs
nodejs
nodejs_crypto
6x
68
at least 2048 bits and that of the curve of ECDSA and ECDH at least 224 bits, to be safe to use for several years. * 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. ## Crypto Constants[#](#cryp...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
0b195b4d-1c58-57c1-8505-115adcc2b0b7
docs
nodejs
nodejs_crypto
6x
69
| `SSL_OP_CIPHER_SERVER_PREFERENCE` | Attempts to use the server's preferences instead of the client's when selecting a cipher. Behavior depends on protocol version. See <https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html>. | | `SSL_OP_CISCO_ANYCONNECT` | Instructs OpenSSL to use Cisco's "speshul" versi...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
cd6fe2b0-7d1e-5528-8532-452f85efc941
docs
nodejs
nodejs_crypto
6x
70
| `SSL_OP_MSIE_SSLV2_RSA_PADDING` | Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. | | `SSL_OP_NETSCAPE_CA_DN_BUG` | | | `SSL_OP_NETSCAPE_CHALLENGE_BUG` | | | `SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG` | | | `SSL_OP_NETSCAPE_REUS...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
adc22a63-32d2-5662-97de-b44a633f808d
docs
nodejs
nodejs_crypto
6x
71
`SSL_OP_PKCS1_CHECK_1` | || `SSL_OP_PKCS1_CHECK_2` | | | `SSL_OP_SINGLE_DH_USE` | Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. | | `SSL_OP_SINGLE_ECDH_USE` | Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. | `SSL_OP_SSLEAY_08...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
3b78aa08-6d49-54b8-82cf-076411952df5
docs
nodejs
nodejs_crypto
6x
72
| `ENGINE_METHOD_CIPHERS` | Limit engine usage to CIPHERS | | `ENGINE_METHOD_DIGESTS` | Limit engine usage to DIGESTS | | `ENGINE_METHOD_STORE` | Limit engine usage to STORE | | `ENGINE_METHOD_PKEY_METHS` | Limit engine usage to PKEY\_METHDS | | `ENGINE_METHOD_PKEY_ASN1_METHS` | Limit engine usage to PKEY\_ASN1\_METHS ...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
d4af29db-921f-5bc2-aba9-5161ee147393
docs
nodejs
nodejs_crypto
6x
73
| `RSA_PSS_SALTLEN_MAX_SIGN` | Sets the salt length for `RSA_PKCS1_PSS_PADDING` to the maximum permissible value when signing data. | | `RSA_PSS_SALTLEN_AUTO` | Causes the salt length for `RSA_PKCS1_PSS_PADDING` to be determined automatically when verifying a signature. | | `POINT_CONVERSION_COMPRESSED` | | | `POINT_C...
large_dataset/raw/docs/nodejs/crypto/crypto_6x.md
273be67d-08b6-56e2-9609-76039df29132
docs
nodejs
nodejs_crypto
7x
0
# Crypto# Source: https://nodejs.org/docs/latest-v7.x/api/crypto.html Version: 7.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_7x.md
b02c3fd3-efbd-5e6e-88cf-5944033a985e
docs
nodejs
nodejs_crypto
7x
1
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 now specified formally as part of [HTML5's `keygen` element](http://www.w3.org/TR/html5/forms.html#the-keyg...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
8ee69424-6152-55b5-aa3c-e94d5a6fbdd9
docs
nodejs
nodejs_crypto
7x
2
### certificate.exportChallenge(spkac)[#](#crypto_certificate_exportchallenge_spkac) Added in: v0.11.8 The `spkac` data structure includes a public key and a challenge. The `certificate.exportChallenge()` returns the challenge component in the form of a Node.js [`Buffer`](buffer.html). The `spkac` argument can be eit...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
9d5ad907-843b-5864-a7c0-ac181b03c0a0
docs
nodejs
nodejs_crypto
7x
3
const spkac = getSpkacSomehow(); const publicKey = cert.exportPublicKey(spkac); console.log(publicKey); // Prints: the public key as <Buffer ...> ``` ### certificate.verifySpkac(spkac)[#](#crypto_certificate_verifyspkac_spkac) Added in: v0.11.8 Returns `true` if the given `spkac` data structure is valid, `false` oth...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
aa38f757-8aa2-59af-8c48-fbb7dcf10b70
docs
nodejs
nodejs_crypto
7x
4
* Using the [`cipher.update()`](#crypto_cipher_update_data_input_encoding_output_encoding) and [`cipher.final()`](#crypto_cipher_final_output_encoding) methods to produce the encrypted data. The [`crypto.createCipher()`](#crypto_crypto_createcipher_algorithm_password) or [`crypto.createCipheriv()`](#crypto_crypto_cr...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
eeee8d2b-c475-59e2-87da-a83ce045c263
docs
nodejs
nodejs_crypto
7x
5
const crypto = require('crypto'); const fs = require('fs'); const cipher = crypto.createCipher('aes192', 'a password'); const input = fs.createReadStream('test.js'); const output = fs.createWriteStream('test.enc'); input.pipe(cipher).pipe(output); ``` Example: Using the [`cipher.update()`](#crypto_cipher_update_data...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
7ea963dc-01bb-5611-b304-b12709559c0b
docs
nodejs
nodejs_crypto
7x
6
If an `output_encoding` is not provided, a [`Buffer`](buffer.html) is returned. Once the `cipher.final()` method has been called, the `Cipher` object can no longer be used to encrypt data. Attempts to call `cipher.final()` more than once will result in an error being thrown. ### cipher.setAAD(buffer)[#](#crypto_ciphe...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
4365ff97-1940-5d66-ad1f-d34d0d9d46ea
docs
nodejs
nodejs_crypto
7x
7
been completed using the [`cipher.final()`](#crypto_cipher_final_output_encoding) method. ### cipher.setAutoPadding(auto\_padding=true)[#](#crypto_cipher_setautopadding_auto_padding_true) Added in: v0.7.1 When using block encryption algorithms, the `Cipher` class will automatically add padding to the input data to t...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
1aee7666-b59e-5000-ba9f-4f0af224a31a
docs
nodejs
nodejs_crypto
7x
8
### cipher.update(data[, input\_encoding][, output\_encoding])[#](#crypto_cipher_update_data_input_encoding_output_encoding) History | Version | Changes | | --- | --- | | v6.0.0 | The default `input_encoding` changed from `binary` to `utf8`. | | v0.1.94 | Added in: v0.1.94 | Updates the cipher with `data`. If the `i...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
d785d537-385e-5810-ae42-1ddd7b255d69
docs
nodejs
nodejs_crypto
7x
9
[`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) Added in: v0.1.94 Instances of the `Decipher` class are used to decrypt data...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
66a359b4-6ec2-5b7e-8b39-daaec3ec2f99
docs
nodejs
nodejs_crypto
7x
10
Example: Using `Decipher` objects as streams: ```None const crypto = require('crypto'); const decipher = crypto.createDecipher('aes192', 'a password'); let decrypted = ''; decipher.on('readable', () => { const data = decipher.read(); if (data) decrypted += data.toString('utf8'); }); decipher.on('end', () => {...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
e76329d5-d12a-57a7-b137-353108b7136d
docs
nodejs
nodejs_crypto
7x
11
```None const crypto = require('crypto'); const decipher = crypto.createDecipher('aes192', 'a password'); const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); // Prin...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
5dcc13b7-b4f3-5e2e-a185-98dc0138ca54
docs
nodejs
nodejs_crypto
7x
12
### decipher.setAAD(buffer)[#](#crypto_decipher_setaad_buffer) History | Version | Changes | | --- | --- | | v7.2.0 | This method now returns a reference to `decipher`. | | v1.0.0 | Added in: v1.0.0 | When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAAD()` method sets...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
7b089413-718a-5d08-98ca-549bcd18a8cc
docs
nodejs
nodejs_crypto
7x
13
cipher text should be discarded due to failed authentication. Returns `this` for method chaining. ### decipher.setAutoPadding(auto\_padding=true)[#](#crypto_decipher_setautopadding_auto_padding_true) Added in: v0.7.1 When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
76f091a9-5e70-5e97-8ed5-0a4932d8753c
docs
nodejs
nodejs_crypto
7x
14
| v0.1.94 | Added in: v0.1.94 | Updates the decipher with `data`. If the `input_encoding` argument is given, its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` argument is a string using the specified encoding. If the `input_encoding` argument is not given, `data` must be a [`Buffer`](buffer.ht...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
43ca1d4b-60d9-547e-bbc0-8a4d278c8535
docs
nodejs
nodejs_crypto
7x
15
## Class: DiffieHellman[#](#crypto_class_diffiehellman) Added in: v0.5.0 The `DiffieHellman` class is a utility for creating Diffie-Hellman key exchanges. Instances of the `DiffieHellman` class can be created using the [`crypto.createDiffieHellman()`](#crypto_crypto_creatediffiehellman_prime_prime_encoding_generator...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
53a4f27f-aef9-5567-af58-0f7204c400ae
docs
nodejs
nodejs_crypto
7x
16
### diffieHellman.computeSecret(other\_public\_key[, input\_encoding][, output\_encoding])[#](#crypto_diffiehellman_computesecret_other_public_key_input_encoding_output_encoding) Added in: v0.5.0 Computes the shared secret using `other_public_key` as the other party's public key and returns the computed shared secret...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
e8fe96bd-e716-59f8-ad6b-d2ed1e676e98
docs
nodejs
nodejs_crypto
7x
17
or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html) is returned. ### diffieHellman.getGenerator([encoding])[#](#crypto_diffiehellman_getgenerator_encoding) Added in: v0.5.0 Returns the Diffie-Hellman generator in the specified `encoding`, which can be `'latin1'`, `'hex'...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
681bf61e-a2a0-517b-b00a-7dd674b3cf4a
docs
nodejs
nodejs_crypto
7x
18
string is returned; otherwise a [`Buffer`](buffer.html) is returned. ### diffieHellman.getPublicKey([encoding])[#](#crypto_diffiehellman_getpublickey_encoding) Added in: v0.5.0 Returns the Diffie-Hellman public key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provide...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
2bc65ff9-f1bb-580f-9ce0-9dc18f4b0893
docs
nodejs
nodejs_crypto
7x
19
and is either `'latin1'`, `'hex'` or `'base64'`, `public_key` is expected to be a string. If no `encoding` is provided, `public_key` is expected to be a [`Buffer`](buffer.html). ### diffieHellman.verifyError[#](#crypto_diffiehellman_verifyerror) Added in: v0.11.12 A bit field containing any warnings and/or errors re...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
d63d0b27-d990-5c19-8b08-27a2fb2f4ac8
docs
nodejs
nodejs_crypto
7x
20
const alice = crypto.createECDH('secp521r1'); const aliceKey = alice.generateKeys(); // Generate Bob's keys... const bob = crypto.createECDH('secp521r1'); const bobKey = bob.generateKeys(); // Exchange and generate the secret... const aliceSecret = alice.computeSecret(bobKey); const bobSecret = bob.computeSecret(alic...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
625675de-7563-5889-af1c-a74cd25464fc
docs
nodejs
nodejs_crypto
7x
21
`'latin1'`, `'hex'`, or `'base64'`. If the `input_encoding` is not provided, `other_public_key` is expected to be a [`Buffer`](buffer.html). If `output_encoding` is given a string will be returned; otherwise a [`Buffer`](buffer.html) is returned. ### ecdh.generateKeys([encoding[, format]])[#](#crypto_ecdh_generatekey...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
6d5ef8a2-531c-5a13-be2d-5a4dea821e27
docs
nodejs
nodejs_crypto
7x
22
### ecdh.getPrivateKey([encoding])[#](#crypto_ecdh_getprivatekey_encoding) Added in: v0.11.14 Returns the EC Diffie-Hellman private key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`](buffer.html) is returned. ### ec...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
be67ff2f-e1fb-547e-b475-ba49b8f2c948
docs
nodejs
nodejs_crypto
7x
23
### ecdh.setPrivateKey(private\_key[, encoding])[#](#crypto_ecdh_setprivatekey_private_key_encoding) Added in: v0.11.14 Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'`, `'hex'` or `'base64'`. If `encoding` is provided, `private_key` is expected to be a string; otherwise `private_key` is expec...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
5b374ce1-a8a4-59dc-b8b8-e1ef47ee1413
docs
nodejs
nodejs_crypto
7x
24
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 to compute the shared secret. Typically either [`ecdh.generateKeys()`](#crypto_ecdh_generatekeys_encoding_format) or [`ecdh.setPrivateKey()`](#crypto_ecdh_setprivatekey_private_key_en...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
fae10fd6-1408-5cf7-9dd6-104168bf847f
docs
nodejs
nodejs_crypto
7x
25
bob.generateKeys(); const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); // aliceSecret and bobSecret should be the same shared secret value console.log(aliceSecret === bobSecret); ``` ## Class: Hash[#](#crypto_class_hash) ...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md
3bb62013-8853-5127-a332-acf01871ca3d
docs
nodejs
nodejs_crypto
7x
26
const hash = crypto.createHash('sha256'); hash.on('readable', () => { const data = hash.read(); if (data) console.log(data.toString('hex')); // Prints: // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 }); hash.write('some data to hash'); hash.end(); ``` Example: Using `Hash` and ...
large_dataset/raw/docs/nodejs/crypto/crypto_7x.md