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 |
|---|---|---|---|---|---|---|---|
183947c4-8785-5904-9ec7-f9e07247931c | docs | nodejs | nodejs_crypto | 11x | 85 | | v0.1.94 | Added in: v0.1.94 |
* `algorithm` [<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) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://de... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
a5f8c29d-43e0-5cf0-a974-6c80de09037c | docs | nodejs | nodejs_crypto | 11x | 86 | * `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: [<Decipher>](crypto.html#crypto_class_decipher)
Creates and returns a `Decipher` object that uses the given `algorithm... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3d1c537f-422a-5fe1-8ee4-ccc6083c7f47 | docs | nodejs | nodejs_crypto | 11x | 87 | display the available cipher algorithms.
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 `'utf8'` encoded strings,
[Buffers](buffer.html), `TypedArray`, or `DataView`s. The `key` may optionally be
a [`K... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1e66f931-9503-5b9f-8597-592db645f681 | docs | nodejs | nodejs_crypto | 11x | 88 | ### crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])[[src]](https://github.com/nodejs/node/blob/v11.15.0^0/lib/crypto.js#L123)[#](#crypto_crypto_creatediffiehellman_prime_primeencoding_generator_generatorencoding)
History
| Version | Changes |
| --- | --- |
| v8.0.0 | The `prime` a... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
818e59aa-b45a-54af-9732-fdb1c2364faf | docs | nodejs | nodejs_crypto | 11x | 89 | * `primeEncoding` [<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 `prime` string.
* `generator` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | [<st... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6acdbebf-323c-5620-8eb3-9a6bb5e09a0f | docs | nodejs | nodejs_crypto | 11x | 90 | Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
optional specific `generator`.
The `generator` argument can be a number, string, or [`Buffer`](buffer.html). If
`generator` is not specified, the value `2` is used.
If `primeEncoding` is specified, `prime` is expected to be a string; othe... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
744d69b4-3824-54c4-b49a-775605b371b0 | docs | nodejs | nodejs_crypto | 11x | 91 | * `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_11x.md |
25442b43-926f-5090-a016-cb27de7a0a55 | docs | nodejs | nodejs_crypto | 11x | 92 | * `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_11x.md |
b103df7a-f87f-52b9-9361-09b0afdb18eb | docs | nodejs | nodejs_crypto | 11x | 93 | * Returns: [<Hash>](crypto.html#crypto_class_hash)
Creates and returns a `Hash` object that can be used to generate hash digests
using the given `algorithm`. Optional `options` argument controls stream
behavior.
The `algorithm` is dependent on the available algorithms supported by the
version of OpenSSL on the platfo... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ab20c87c-8872-5a5c-88aa-5d7461b38876 | docs | nodejs | nodejs_crypto | 11x | 94 | ```
### crypto.createHmac(algorithm, key[, options])[[src]](https://github.com/nodejs/node/blob/v11.15.0^0/lib/crypto.js#L135)[#](#crypto_crypto_createhmac_algorithm_key_options)
History
| Version | Changes |
| --- | --- |
| v11.6.0 | The `key` argument can now be a `KeyObject`. |
| v0.1.94 | Added in: v0.1.94 |
* ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d1533383-a8e0-5c0d-8ee6-f7e7898d00da | docs | nodejs | nodejs_crypto | 11x | 95 | * `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_11x.md |
32cc7cee-6d42-5e59-b824-5f83deab35ba | docs | nodejs | nodejs_crypto | 11x | 96 | const hmac = crypto.createHmac('sha256', 'a secret');
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')} ${filena... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
62169ad8-d0ec-54ac-830c-9bac66e0612a | docs | nodejs | nodejs_crypto | 11x | 97 | + `format`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be `'pem'` or `'der'`. **Default:** `'pem'`.
+ `type`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be `'pkcs1'`, `'pkcs8'` or `'sec1'`. This optio... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d1582bb5-bde6-547e-b6bf-273ab9cf45af | docs | nodejs | nodejs_crypto | 11x | 98 | ### crypto.createPublicKey(key)[#](#crypto_crypto_createpublickey_key)
History
| Version | Changes |
| --- | --- |
| v11.13.0 | The `key` argument can now be a `KeyObject` with type `private`. |
| v11.7.0 | The `key` argument can now be a private key. |
| v11.6.0 | Added in: v11.6.0 |
* `key` [<Object>](https://deve... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d2aa447e-579c-5189-ba17-4677ed122bae | docs | nodejs | nodejs_crypto | 11x | 99 | + `type`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Must be `'pkcs1'` or `'spki'`. This option is required
only if the `format` is `'der'`.
* Returns: [<KeyObject>](crypto.html#crypto_class_keyobject)
Creates and returns a new key object containing a public k... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
07806de4-90d4-5eec-a6c8-761247dbc03d | docs | nodejs | nodejs_crypto | 11x | 100 | extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type
`'private'` is given, a new `KeyObject` with type `'public'` will be returned
and it will be impossible to extract the private key from the returned object.
### crypto.createSecretKey(key)[#](#crypto_crypto_createsecretkey_key)
Added in: v... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
2b910d77-4e0f-548e-b05f-589ecb506f7c | docs | nodejs | nodejs_crypto | 11x | 101 | * `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) [`stream.Writable` options](stream.html#stream_constructor_new_stream_writable_options)
* Returns: [<Sign>](crypto.html#crypto_class_sign)
Creates and returns a `Sign` object that uses the given `algorithm`.... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d6a16a5e-9903-5665-97f7-4c169678cdb7 | docs | nodejs | nodejs_crypto | 11x | 102 | ### crypto.createVerify(algorithm[, options])[[src]](https://github.com/nodejs/node/blob/v11.15.0^0/lib/crypto.js#L143)[#](#crypto_crypto_createverify_algorithm_options)
Added in: v0.1.92
* `algorithm` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* `options` [<Object... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
cd75a36c-b4f7-55c7-a8fa-53477f0c4d3a | docs | nodejs | nodejs_crypto | 11x | 103 | the corresponding digest algorithm. This does not work for all signature
algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
algorithm names.
### crypto.generateKeyPair(type, options, callback)[#](#crypto_crypto_generatekeypair_type_options_callback)
History
| Version | Changes |
| --- | --... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d3d18ba8-287b-595c-8846-48e8e50d7523 | docs | nodejs | nodejs_crypto | 11x | 104 | + `publicExponent`: [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Public exponent (RSA). **Default:** `0x10001`.
+ `divisorLength`: [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Size of `q` in bits (DSA).
+ `namedC... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
bac4d1b3-c789-51af-af69-941832527005 | docs | nodejs | nodejs_crypto | 11x | 105 | + `err`: [<Error>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
+ `publicKey`: [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<KeyObject>](crypto.html#crypto_class_keyobject)
... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
7c5ada79-7e37-5ec2-8bd7-1bb8262372b1 | docs | nodejs | nodejs_crypto | 11x | 106 | `'pkcs8'` with encryption for long-term storage:
```None
const { generateKeyPair } = require('crypto');
generateKeyPair('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: 'aes-256-cbc',
passphrase... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1ff9685b-35de-5f82-90ab-357d6c8d2d97 | docs | nodejs | nodejs_crypto | 11x | 107 | | v11.6.0 | The `generateKeyPair` and `generateKeyPairSync` functions now produce key objects if no encoding was specified. |
| v10.12.0 | 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`: [<Ob... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6ff21519-8aa8-5afd-a8a2-3dee30a96997 | docs | nodejs | nodejs_crypto | 11x | 108 | + `publicKeyEncoding`: [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) See [`keyObject.export()`](#crypto_keyobject_export_options).
+ `privateKeyEncoding`: [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) See [`k... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
5e499706-b507-5174-8089-e439f220eea8 | docs | nodejs | nodejs_crypto | 11x | 109 | If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
behaves as if [`keyObject.export()`](#crypto_keyobject_export_options) had been called on its result. Otherwise,
the respective part of the key is returned as a [`KeyObject`](#crypto_class_keyobject).
When encoding public keys, it is recomme... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c500c223-20f5-58b8-b5eb-35569bfdb300 | docs | nodejs | nodejs_crypto | 11x | 110 | it will be a buffer containing the data encoded as DER.
### crypto.getCiphers()[#](#crypto_crypto_getciphers)
Added in: v0.9.3
* Returns: [<string[]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) An array with the names of the supported cipher
algorithms.
```None
const ciph... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3f8de36c-f589-5485-96e3-5f62e37ca02c | docs | nodejs | nodejs_crypto | 11x | 111 | * Returns: [<DiffieHellman>](crypto.html#crypto_class_diffiehellman)
Creates a predefined `DiffieHellman` key exchange object. The
supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
[RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see [Caveats](#crypto_support_for_weak_or_compromised_algorith... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
2e3dceff-2790-5953-b956-a351588c4d3f | docs | nodejs | nodejs_crypto | 11x | 112 | const crypto = require('crypto');
const alice = crypto.getDiffieHellman('modp14');
const bob = crypto.getDiffieHellman('modp14');
alice.generateKeys();
bob.generateKeys();
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
87026605-58b8-5088-9856-f7839f544d06 | docs | nodejs | nodejs_crypto | 11x | 113 | const hashes = crypto.getHashes();
console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
```
### crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)[#](#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback)
History
| Version | Changes |
| --- | --- |
| v8.0.0 | The `digest` para... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3b382357-0b8a-545c-a394-1a09058cd715 | docs | nodejs | nodejs_crypto | 11x | 114 | * `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_11x.md |
8cab86e2-13e9-5a50-aa7d-67f3a3bbc84f | docs | nodejs | nodejs_crypto | 11x | 115 | Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
implementation. A selected HMAC digest algorithm specified by `digest` is
applied to derive a key of the requested byte length (`keylen`) from the
`password`, `salt` and `iterations`.
The supplied `callback` function is called with two argument... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
8e0a8a64-b0fe-5ddd-baf9-b3ade2e4b5f8 | docs | nodejs | nodejs_crypto | 11x | 116 | 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');
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4e8edd68-1131-5107-ae61-6d3196ef513e | docs | nodejs | nodejs_crypto | 11x | 117 | Note that this API uses libuv's threadpool, which can have surprising and
negative performance implications for some applications, see the
[`UV_THREADPOOL_SIZE`](cli.html#cli_uv_threadpool_size_size) documentation for more information.
### crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)[#](#crypto_crypto... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
713aee72-ef96-5467-a586-a5f4e6a47161 | docs | nodejs | nodejs_crypto | 11x | 118 | * `password` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1b8d818e-8cfe-5440-8ff9-22406a584725 | docs | nodejs | nodejs_crypto | 11x | 119 | * `digest` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [<Buffer>](buffer.html#buffer_class_buffer)
Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
implementation. A selected HMAC digest algorithm specified by `digest` is
applied to... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
1c537c0c-8a3f-5d01-af17-ef96e27251ae | docs | nodejs | nodejs_crypto | 11x | 120 | 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');
const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
console.log(key.toString('hex')); // '3745e48...08d59ae'... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
e9d91cbb-8c4b-5291-9bdf-1c814ead7d57 | docs | nodejs | nodejs_crypto | 11x | 121 | | v0.11.14 | 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#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<KeyObject>](crypto.htm... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
c1bd22be-17e8-5016-a8f9-b956fc297603 | docs | nodejs | nodejs_crypto | 11x | 122 | Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
the corresponding public key, for example using [`crypto.publicEncrypt()`](#crypto_crypto_publicencrypt_key_buffer).
If `privateKey` is not a [`KeyObject`](#crypto_class_keyobject), this function behaves as if
`privateKey` had been passed to ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
320a81b5-0683-58fb-8966-a2757efd512d | docs | nodejs | nodejs_crypto | 11x | 123 | * `privateKey` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<KeyObject>](crypto.html#crypto_class_keyobject)
+ `key... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3ed2eb8f-e590-5494-a9d4-8f22101ccce1 | docs | nodejs | nodejs_crypto | 11x | 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)
* Returns: [<Buffer>](buffer.html#buffer_class_bu... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4cd14952-1bb1-5098-91b2-d0b9c26f0d0d | docs | nodejs | nodejs_crypto | 11x | 125 | ### crypto.publicDecrypt(key, buffer)[#](#crypto_crypto_publicdecrypt_key_buffer)
History
| Version | Changes |
| --- | --- |
| v11.6.0 | This function now supports key objects. |
| v1.1.0 | Added in: v1.1.0 |
* `key` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
bb326e5b-72b2-5758-b55e-d0d03e6dd87f | docs | nodejs | nodejs_crypto | 11x | 126 | * `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_11x.md |
66f23a18-ecd9-50a3-a999-1658cd548679 | docs | nodejs | nodejs_crypto | 11x | 127 | ### crypto.publicEncrypt(key, buffer)[#](#crypto_crypto_publicencrypt_key_buffer)
History
| Version | Changes |
| --- | --- |
| v11.6.0 | This function now supports key objects. |
| v0.11.14 | Added in: v0.11.14 |
* `key` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Obj... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
99cf5ada-90bc-5ba5-8a1b-0a2a9774b61c | docs | nodejs | nodejs_crypto | 11x | 128 | + `padding` [<crypto.constants>](crypto.html#crypto_crypto_constants_1) An optional padding value defined in
`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_cla... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
11d5a3ab-37d4-5066-8671-faef069870b7 | docs | nodejs | nodejs_crypto | 11x | 129 | `key` had been passed to [`crypto.createPublicKey()`](#crypto_crypto_createpublickey_key). If it is an
object, the `padding` property can be passed. Otherwise, this function uses
`RSA_PKCS1_OAEP_PADDING`.
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
##... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
a0e8dcae-7dbc-5575-9149-f1312e254bc7 | docs | nodejs | nodejs_crypto | 11x | 130 | * Returns: [<Buffer>](buffer.html#buffer_class_buffer) if the `callback` function is not provided.
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 the `ca... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
223452fe-82e0-57d4-9e84-ff37a13e02af | docs | nodejs | nodejs_crypto | 11x | 131 | `${buf.length} bytes of random data: ${buf.toString('hex')}`);
```
The `crypto.randomBytes()` method will not complete until there is
sufficient entropy available.
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 ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b9ae867b-859c-5dd0-95b9-a4ef333a0e94 | docs | nodejs | nodejs_crypto | 11x | 132 | ### crypto.randomFillSync(buffer[, offset][, size])[#](#crypto_crypto_randomfillsync_buffer_offset_size)
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#buffer_cla... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
cbc5277f-4369-5086-9f20-bf956a93ec3f | docs | nodejs | nodejs_crypto | 11x | 133 | * Returns: [<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) The object passed as `buffer` argument.
Synchron... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
85e522bf-08f1-51ff-b312-7b529fd31c52 | docs | nodejs | nodejs_crypto | 11x | 134 | b.byteOffset, b.byteLength).toString('hex'));
const c = new DataView(new ArrayBuffer(10));
console.log(Buffer.from(crypto.randomFillSync(c).buffer,
c.byteOffset, c.byteLength).toString('hex'));
```
### crypto.randomFill(buffer[, offset][, size], callback)[#](#crypto_cry... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
94bbc508-1041-5b31-9c81-0d882dbe45f4 | docs | nodejs | nodejs_crypto | 11x | 135 | * `size` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) **Default:** `buffer.length - offset`
* `callback` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) `function(err, buf) {}`.
This function is similar to [`cryp... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
54135544-ca7d-5ba1-bc6e-820022af787b | docs | nodejs | nodejs_crypto | 11x | 136 | Any `TypedArray` or `DataView` instance may be passed as `buffer`.
```None
const a = new Uint32Array(10);
crypto.randomFill(a, (err, buf) => {
if (err) throw err;
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
.toString('hex'));
});
const b = new Float64Array(10);
crypto.randomFill(b, (er... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
96ac07ae-56fd-5ff0-8328-4949a60ec65d | docs | nodejs | nodejs_crypto | 11x | 137 | threadpool request. To minimize threadpool task length variation, partition
large `randomFill` requests when doing so as part of fulfilling a client
request.
### crypto.scrypt(password, salt, keylen[, options], callback)[#](#crypto_crypto_scrypt_password_salt_keylen_options_callback)
History
| Version | Changes |
| ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b78e1c8a-b77a-5a0d-8854-8cf8eed33df5 | docs | nodejs | nodejs_crypto | 11x | 138 | * `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_11x.md |
499e5754-d148-5916-8e38-c99ac186d1dc | docs | nodejs | nodejs_crypto | 11x | 139 | + `parallelization` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Parallelization parameter. **Default:** `1`.
+ `N` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Alias for `cost`. Only one of both may be specified.
... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
69b6a875-d632-5e6f-97c0-2e6dcc6278e9 | docs | nodejs | nodejs_crypto | 11x | 140 | + `err` [<Error>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
+ `derivedKey` [<Buffer>](buffer.html#buffer_class_buffer)
Provides an asynchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based
key derivation function that is des... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
3e5dae12-1f82-5338-92db-c1be064040c1 | docs | nodejs | nodejs_crypto | 11x | 141 | // Using the factory defaults.
crypto.scrypt('secret', 'salt', 64, (err, derivedKey) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
});
// Using a custom N parameter. Must be a power of two.
crypto.scrypt('secret', 'salt', 64, { N: 1024 }, (err, derivedKey) => {
if (err)... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
0816dd43-2e13-58af-abea-44c4b1356b8d | docs | nodejs | nodejs_crypto | 11x | 142 | * `password` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Buffer>](buffer.html#buffer_class_buffer) | [<TypedArray>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) | [<DataView>](https://developer.mozilla.org/en-US/docs... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
5198a831-45e0-5c64-b0c7-a3eaa0d4930b | docs | nodejs | nodejs_crypto | 11x | 143 | + `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
than one. **Default:** `16384`.
+ `blockSize` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Block s... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
33f39d70-7be6-52bf-b89b-2dcce31ea72d | docs | nodejs | nodejs_crypto | 11x | 144 | + `maxmem` [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Memory upper bound. It is an error when (approximately)
`128 * N * r > maxmem`. **Default:** `32 * 1024 * 1024`.
* Returns: [<Buffer>](buffer.html#buffer_class_buffer)
Provides a synchronous [scrypt](https:... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
ef926b1d-95e9-54a3-a9d4-e4863bd70552 | docs | nodejs | nodejs_crypto | 11x | 145 | // Using the factory defaults.
const key1 = crypto.scryptSync('secret', 'salt', 64);
console.log(key1.toString('hex')); // '3745e48...08d59ae'
// Using a custom N parameter. Must be a power of two.
const key2 = crypto.scryptSync('secret', 'salt', 64, { N: 1024 });
console.log(key2.toString('hex')); // '3745e48...aa39... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
4daadd29-1c49-5263-84cc-9f29ffc84b18 | docs | nodejs | nodejs_crypto | 11x | 146 | * `crypto.constants.ENGINE_METHOD_RSA`
* `crypto.constants.ENGINE_METHOD_DSA`
* `crypto.constants.ENGINE_METHOD_DH`
* `crypto.constants.ENGINE_METHOD_RAND`
* `crypto.constants.ENGINE_METHOD_EC`
* `crypto.constants.ENGINE_METHOD_CIPHERS`
* `crypto.constants.ENGINE_METHOD_DIGESTS`
* `crypto.constants.ENGINE_METHOD_PKEY_M... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
899f219b-7849-5afc-a4f4-3e18b82efc39 | docs | nodejs | nodejs_crypto | 11x | 147 | ### crypto.timingSafeEqual(a, b)[#](#crypto_crypto_timingsafeequal_a_b)
Added in: v6.6.0
* `a` [<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/JavaScrip... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
191aef9a-7e3b-5e3f-93af-7a5742c42168 | docs | nodejs | nodejs_crypto | 11x | 148 | [capability urls](https://www.w3.org/TR/capability-urls/).
`a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
must have the same length.
Use of `crypto.timingSafeEqual` does not guarantee that the *surrounding* code
is timing-safe. Care should be taken to ensure that the surrounding code does... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
47b17246-81ad-52bc-b1f7-a52ff327be81 | docs | nodejs | nodejs_crypto | 11x | 149 | 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_privatekey_encoding) can be c... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
9c4afdea-b6e2-5983-a524-09fbbb0275c0 | docs | nodejs | nodejs_crypto | 11x | 150 | should be called. The main drawback of using [`ecdh.setPublicKey()`](#crypto_ecdh_setpublickey_publickey_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 still... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
60292368-16d4-5929-8f1a-72abf671e6a1 | docs | nodejs | nodejs_crypto | 11x | 151 | 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.
### CCM mode[#](#crypto_ccm_... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
9a8b3075-0d68-539e-8ebf-4c556cd1ef44 | docs | nodejs | nodejs_crypto | 11x | 152 | Otherwise, decryption will fail and `final()` will throw an error in
compliance with section 2.6 of [RFC 3610](https://www.rfc-editor.org/rfc/rfc3610.txt).
* Using stream methods such as `write(data)`, `end(data)` or `pipe()` in CCM
mode might fail as CCM cannot handle more than one chunk of data per instance.
* ... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d4251b71-f427-5540-862e-1c2e577ec18f | docs | nodejs | nodejs_crypto | 11x | 153 | });
const plaintext = 'Hello world';
cipher.setAAD(aad, {
plaintextLength: Buffer.byteLength(plaintext)
});
const ciphertext = cipher.update(plaintext, 'utf8');
cipher.final();
const tag = cipher.getAuthTag();
// Now transmit { ciphertext, nonce, tag }.
const decipher = crypto.createDecipheriv('aes-192-ccm', key, n... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
bbd6c2c6-3025-566b-b03a-4c99baaec96b | docs | nodejs | nodejs_crypto | 11x | 154 | ### OpenSSL Options[#](#crypto_openssl_options)
| Constant | Description |
| --- | --- |
| `SSL_OP_ALL` | Applies multiple bug workarounds within OpenSSL. See <https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html> for detail. |
| `SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION` | Allows legacy insecure renegot... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
6d461776-ca74-5abc-9166-8893e3cec07b | docs | nodejs | nodejs_crypto | 11x | 155 | | `SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS` | Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. |
| `SSL_OP_EPHEMERAL_RSA` | Instructs OpenSSL to always use the tmp\_rsa key when performing RSA operations. |
| `SSL_OP_LEGACY_SERVER_CONNECT` | Allows initial connection to server... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
b1c1c612-228e-5b9c-969b-e7f3b792e3b4 | docs | nodejs | nodejs_crypto | 11x | 156 | | `SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION` | Instructs OpenSSL to always start a new session when performing renegotiation. |
| `SSL_OP_NO_SSLv2` | Instructs OpenSSL to turn off SSL v2 |
| `SSL_OP_NO_SSLv3` | Instructs OpenSSL to turn off SSL v3 |
| `SSL_OP_NO_TICKET` | Instructs OpenSSL to disable use of RFC450... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
eb176def-19c5-53c4-8e5d-6483f99a3412 | docs | nodejs | nodejs_crypto | 11x | 157 | | `SSL_OP_TLS_ROLLBACK_BUG` | Instructs OpenSSL to disable version rollback attack detection. |
### OpenSSL Engine Constants[#](#crypto_openssl_engine_constants)
| Constant | Description |
| --- | --- |
| `ENGINE_METHOD_RSA` | Limit engine usage to RSA |
| `ENGINE_METHOD_DSA` | Limit engine usage to DSA |
| `ENGINE_M... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
d8df4417-c66b-5a3a-839d-aa13b5756393 | docs | nodejs | nodejs_crypto | 11x | 158 | | `DH_NOT_SUITABLE_GENERATOR` | |
| `ALPN_ENABLED` | |
| `RSA_PKCS1_PADDING` | |
| `RSA_SSLV23_PADDING` | |
| `RSA_NO_PADDING` | |
| `RSA_PKCS1_OAEP_PADDING` | |
| `RSA_X931_PADDING` | |
| `RSA_PKCS1_PSS_PADDING` | |
| `RSA_PSS_SALTLEN_DIGEST` | Sets the salt length for `RSA_PKCS1_PSS_PADDING` to the digest siz... | large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
92440390-6f8d-56d8-bde5-b163e78c68a0 | docs | nodejs | nodejs_crypto | 11x | 159 | | `defaultCipherList` | Specifies the active default cipher list used by the current Node.js process. |
| large_dataset/raw/docs/nodejs/crypto/crypto_11x.md |
63af920b-2217-52ae-b10f-d9a01a131eaa | docs | nodejs | nodejs_crypto | 4x | 0 | # Crypto#
Source: https://nodejs.org/docs/latest-v4.x/api/crypto.html
Version: 4.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_4x.md |
c79f7eeb-4ea5-5cf2-a9f4-8e16f92325f5 | docs | nodejs | nodejs_crypto | 4x | 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/man1.0.2/apps/spkac.html) internally.
### new crypto.Certificate()[#](#crypto_new_crypto_certificate)
Instances of the `Certificate` class can be created... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
8525131d-1fe9-5551-9247-9f35e5c4ab3e | docs | nodejs | nodejs_crypto | 4x | 2 | console.log(challenge.toString('utf8'));
// Prints the challenge as a UTF8 string
```
### certificate.exportPublicKey(spkac)[#](#crypto_certificate_exportpublickey_spkac)
Added in: v0.11.8
The `spkac` data structure includes a public key and a challenge. The
`certificate.exportPublicKey()` returns the public key c... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
19af1ede-f985-5bd0-b50b-953f777dc822 | docs | nodejs | nodejs_crypto | 4x | 3 | console.log(cert.verifySpkac(new Buffer(spkac)));
// Prints true or false
```
## Class: Cipher[#](#crypto_class_cipher)
Added in: v0.1.94
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... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
2a5e3a47-c222-5fc2-b8fe-e78b75d4c92d | docs | nodejs | nodejs_crypto | 4x | 4 | var encrypted = '';
cipher.on('readable', () => {
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();
`... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
5ce669c3-6f71-5326-b832-34b85f2bea87 | docs | nodejs | nodejs_crypto | 4x | 5 | console.log(encrypted);
// Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504
```
### cipher.final([output\_encoding])[#](#crypto_cipher_final_output_encoding)
Added in: v0.1.94
Returns any remaining enciphered contents. If `output_encoding`
parameter is one of `'binary'`, `'base64'` or `'hex... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
d0e20d15-a835-5e34-a32b-a1b119e65e81 | docs | nodejs | nodejs_crypto | 4x | 6 | ### cipher.getAuthTag()[#](#crypto_cipher_getauthtag)
Added in: v1.0.0
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.getAut... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
10264c7a-45b5-57fe-87ab-abc50dfe0b6a | docs | nodejs | nodejs_crypto | 4x | 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_4x.md |
25c90c51-8b23-5dbe-83c0-45e3abc5d80e | docs | nodejs | nodejs_crypto | 4x | 8 | `output_encoding` is provided, a [`Buffer`](buffer.html) is returned.
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... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
482eabd8-4e25-578d-adcd-156b994b5fae | docs | nodejs | nodejs_crypto | 4x | 9 | The [`crypto.createDecipher()`](#crypto_crypto_createdecipher_algorithm_password) or [`crypto.createDecipheriv()`](#crypto_crypto_createdecipheriv_algorithm_key_iv) methods are
used to create `Decipher` instances. `Decipher` objects are not to be created
directly using the `new` keyword.
Example: Using `Decipher` obje... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
f8b81ef1-19f8-5e52-af6d-ee9c42710c66 | docs | nodejs | nodejs_crypto | 4x | 10 | const input = fs.createReadStream('test.enc');
const output = fs.createWriteStream('test.js');
input.pipe(decipher).pipe(output);
```
Example: Using the [`decipher.update()`](#crypto_decipher_update_data_input_encoding_output_encoding) and [`decipher.final()`](#crypto_decipher_final_output_encoding) methods:
```None... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
2247c737-c42b-5051-9b71-781231b2444a | docs | nodejs | nodejs_crypto | 4x | 11 | Once the `decipher.final()` method has been called, the `Decipher` object can
no longer be used to decrypt data. Attempts to call `decipher.final()` more
than once will result in an error being thrown.
### decipher.setAAD(buffer)[#](#crypto_decipher_setaad_buffer)
Added in: v1.0.0
When using an authenticated encrypt... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
cd15a965-92af-5620-a012-7685ea7bceec | docs | nodejs | nodejs_crypto | 4x | 12 | ### 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_4x.md |
761379a5-aa5b-5b5d-8675-11d4c390b9e9 | docs | nodejs | nodejs_crypto | 4x | 13 | 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 `'binary'`, `'ascii'` or `'utf8'`. If the `output_encoding`
is specified, a string using the spe... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
62d0e52e-d043-513e-b64f-653bc4cd6f04 | docs | nodejs | nodejs_crypto | 4x | 14 | [`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 alice_key = alice.generateKeys(... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
1d6b6f26-8ec3-56cd-8559-8c45a606801e | docs | nodejs | nodejs_crypto | 4x | 15 | key is interpreted using the specified `input_encoding`, and secret is
encoded using specified `output_encoding`. Encodings can be
`'binary'`, `'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_4x.md |
f1956665-6cc2-57d2-835a-1123bc7d6835 | docs | nodejs | nodejs_crypto | 4x | 16 | be `'binary'`, `'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 `'bina... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
cea057b4-9428-558f-89ac-cfd69747c730 | docs | nodejs | nodejs_crypto | 4x | 17 | can be `'binary'`, `'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_4x.md |
956990e0-a6e7-5556-afc4-189596bc7f1e | docs | nodejs | nodejs_crypto | 4x | 18 | ### 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_4x.md |
315e3fff-b251-5520-bc5d-7d14e1a12003 | docs | nodejs | nodejs_crypto | 4x | 19 | // Exchange and generate the secret...
const alice_secret = alice.computeSecret(bob_key);
const bob_secret = bob.computeSecret(alice_key);
assert(alice_secret, bob_secret);
// OK
```
### ecdh.computeSecret(other\_public\_key[, input\_encoding][, output\_encoding])[#](#crypto_ecdh_computesecret_other_public_key_inpu... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
6807347b-7c4d-5a4f-8328-f1d798f9d6c9 | docs | nodejs | nodejs_crypto | 4x | 20 | ### 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_4x.md |
163b3778-d9bd-5b06-a768-ea103ba227fc | docs | nodejs | nodejs_crypto | 4x | 21 | ### 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_4x.md |
406dbaae-369e-5490-aebf-66c0b0ea9f0d | docs | nodejs | nodejs_crypto | 4x | 22 | 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
```None
Stability: 0 - Deprecated
```... | large_dataset/raw/docs/nodejs/crypto/crypto_4x.md |
56104f5d-23e1-5995-9123-c46a6bb831b0 | docs | nodejs | nodejs_crypto | 4x | 23 | 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_4x.md |
2c1badc2-b452-539d-8d71-73172f50fe15 | docs | nodejs | nodejs_crypto | 4x | 24 | ## 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_4x.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.