@ -168,15 +168,15 @@ console.log(encrypted);
// Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504
// Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504
```
```
### cipher.final([output_e ncoding])
### cipher.final([outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.94
added: v0.1.94
-->
-->
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Returns any remaining enciphered contents. If `output_e ncoding`
Returns any remaining enciphered contents. If `outputE ncoding`
parameter is one of `'latin1'` , `'base64'` or `'hex'` , a string is returned.
parameter is one of `'latin1'` , `'base64'` or `'hex'` , a string is returned.
If an `output_e ncoding` is not provided, a [`Buffer`][] is returned.
If an `outputE ncoding` is not provided, a [`Buffer`][] is returned.
Once the `cipher.final()` method has been called, the `Cipher` object can no
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
longer be used to encrypt data. Attempts to call `cipher.final()` more than
@ -207,18 +207,18 @@ the _authentication tag_ that has been computed from the given data.
The `cipher.getAuthTag()` method should only be called after encryption has
The `cipher.getAuthTag()` method should only be called after encryption has
been completed using the [`cipher.final()`][] method.
been completed using the [`cipher.final()`][] method.
### cipher.setAutoPadding([auto_p adding])
### cipher.setAutoPadding([autoP adding])
<!-- YAML
<!-- YAML
added: v0.7.1
added: v0.7.1
-->
-->
- `auto_p adding` {boolean} Defaults to `true` .
- `autoP adding` {boolean} Defaults to `true` .
- Returns the {Cipher} for method chaining.
- Returns the {Cipher} for method chaining.
When using block encryption algorithms, the `Cipher` class will automatically
When using block encryption algorithms, the `Cipher` class will automatically
add padding to the input data to the appropriate block size. To disable the
add padding to the input data to the appropriate block size. To disable the
default padding call `cipher.setAutoPadding(false)` .
default padding call `cipher.setAutoPadding(false)` .
When `auto_p adding` is `false` , the length of the entire input data must be a
When `autoP adding` is `false` , the length of the entire input data must be a
multiple of the cipher's block size or [`cipher.final()`][] will throw an Error.
multiple of the cipher's block size or [`cipher.final()`][] will throw an Error.
Disabling automatic padding is useful for non-standard padding, for instance
Disabling automatic padding is useful for non-standard padding, for instance
using `0x0` instead of PKCS padding.
using `0x0` instead of PKCS padding.
@ -226,29 +226,29 @@ using `0x0` instead of PKCS padding.
The `cipher.setAutoPadding()` method must be called before
The `cipher.setAutoPadding()` method must be called before
[`cipher.final()`][].
[`cipher.final()`][].
### cipher.update(data[, input_encoding][, output_e ncoding])
### cipher.update(data[, inputEncoding][, outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.94
added: v0.1.94
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Updates the cipher with `data` . If the `input_e ncoding` argument is given,
Updates the cipher with `data` . If the `inputE ncoding` argument is given,
its value must be one of `'utf8'` , `'ascii'` , or `'latin1'` and the `data`
its value must be one of `'utf8'` , `'ascii'` , or `'latin1'` and the `data`
argument is a string using the specified encoding. If the `input_e ncoding`
argument is a string using the specified encoding. If the `inputE ncoding`
argument is not given, `data` must be a [`Buffer`][], `TypedArray` , or
argument is not given, `data` must be a [`Buffer`][], `TypedArray` , or
`DataView` . If `data` is a [`Buffer`][], `TypedArray` , or `DataView` , then
`DataView` . If `data` is a [`Buffer`][], `TypedArray` , or `DataView` , then
`input_e ncoding` is ignored.
`inputE ncoding` is ignored.
The `output_e ncoding` specifies the output format of the enciphered
The `outputE ncoding` specifies the output format of the enciphered
data, and can be `'latin1'` , `'base64'` or `'hex'` . If the `output_e ncoding`
data, and can be `'latin1'` , `'base64'` or `'hex'` . If the `outputE ncoding`
is specified, a string using the specified encoding is returned. If no
is specified, a string using the specified encoding is returned. If no
`output_e ncoding` is provided, a [`Buffer`][] is returned.
`outputE ncoding` is provided, a [`Buffer`][] is returned.
The `cipher.update()` method can be called multiple times with new data until
The `cipher.update()` method can be called multiple times with new data until
[`cipher.final()`][] is called. Calling `cipher.update()` after
[`cipher.final()`][] is called. Calling `cipher.update()` after
@ -321,15 +321,15 @@ console.log(decrypted);
// Prints: some clear text data
// Prints: some clear text data
```
```
### decipher.final([output_e ncoding])
### decipher.final([outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.94
added: v0.1.94
-->
-->
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Returns any remaining deciphered contents. If `output_e ncoding`
Returns any remaining deciphered contents. If `outputE ncoding`
parameter is one of `'latin1'` , `'ascii'` or `'utf8'` , a string is returned.
parameter is one of `'latin1'` , `'ascii'` or `'utf8'` , a string is returned.
If an `output_e ncoding` is not provided, a [`Buffer`][] is returned.
If an `outputE ncoding` is not provided, a [`Buffer`][] is returned.
Once the `decipher.final()` method has been called, the `Decipher` object can
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
no longer be used to decrypt data. Attempts to call `decipher.final()` more
@ -372,11 +372,11 @@ cipher text should be discarded due to failed authentication.
The `decipher.setAuthTag()` method must be called before
The `decipher.setAuthTag()` method must be called before
[`decipher.final()`][].
[`decipher.final()`][].
### decipher.setAutoPadding([auto_p adding])
### decipher.setAutoPadding([autoP adding])
<!-- YAML
<!-- YAML
added: v0.7.1
added: v0.7.1
-->
-->
- `auto_p adding` {boolean} Defaults to `true` .
- `autoP adding` {boolean} Defaults to `true` .
- Returns the {Cipher} for method chaining.
- Returns the {Cipher} for method chaining.
When data has been encrypted without standard block padding, calling
When data has been encrypted without standard block padding, calling
@ -389,28 +389,28 @@ multiple of the ciphers block size.
The `decipher.setAutoPadding()` method must be called before
The `decipher.setAutoPadding()` method must be called before
[`decipher.final()`][].
[`decipher.final()`][].
### decipher.update(data[, input_encoding][, output_e ncoding])
### decipher.update(data[, inputEncoding][, outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.94
added: v0.1.94
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Updates the decipher with `data` . If the `input_e ncoding` argument is given,
Updates the decipher with `data` . If the `inputE ncoding` argument is given,
its value must be one of `'latin1'` , `'base64'` , or `'hex'` and the `data`
its value must be one of `'latin1'` , `'base64'` , or `'hex'` and the `data`
argument is a string using the specified encoding. If the `input_e ncoding`
argument is a string using the specified encoding. If the `inputE ncoding`
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
[`Buffer`][] then `input_e ncoding` is ignored.
[`Buffer`][] then `inputE ncoding` is ignored.
The `output_e ncoding` specifies the output format of the enciphered
The `outputE ncoding` specifies the output format of the enciphered
data, and can be `'latin1'` , `'ascii'` or `'utf8'` . If the `output_e ncoding`
data, and can be `'latin1'` , `'ascii'` or `'utf8'` . If the `outputE ncoding`
is specified, a string using the specified encoding is returned. If no
is specified, a string using the specified encoding is returned. If no
`output_e ncoding` is provided, a [`Buffer`][] is returned.
`outputE ncoding` is provided, a [`Buffer`][] is returned.
The `decipher.update()` method can be called multiple times with new data until
The `decipher.update()` method can be called multiple times with new data until
[`decipher.final()`][] is called. Calling `decipher.update()` after
[`decipher.final()`][] is called. Calling `decipher.update()` after
@ -447,23 +447,23 @@ const bobSecret = bob.computeSecret(aliceKey);
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
```
```
### diffieHellman.computeSecret(other_public_key[, input_encoding][, output_e ncoding])
### diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.5.0
added: v0.5.0
-->
-->
- `other_public_k ey` {string | Buffer | TypedArray | DataView}
- `otherPublicK ey` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Computes the shared secret using `other_public_k ey` as the other
Computes the shared secret using `otherPublicK ey` as the other
party's public key and returns the computed shared secret. The supplied
party's public key and returns the computed shared secret. The supplied
key is interpreted using the specified `input_e ncoding` , and secret is
key is interpreted using the specified `inputE ncoding` , and secret is
encoded using specified `output_e ncoding` . Encodings can be
encoded using specified `outputE ncoding` . Encodings can be
`'latin1'` , `'hex'` , or `'base64'` . If the `input_e ncoding` is not
`'latin1'` , `'hex'` , or `'base64'` . If the `inputE ncoding` is not
provided, `other_public_k ey` is expected to be a [`Buffer`][],
provided, `otherPublicK ey` is expected to be a [`Buffer`][],
`TypedArray` , or `DataView` .
`TypedArray` , or `DataView` .
If `output_e ncoding` is given a string is returned; otherwise, a
If `outputE ncoding` is given a string is returned; otherwise, a
[`Buffer`][] is returned.
[`Buffer`][] is returned.
### diffieHellman.generateKeys([encoding])
### diffieHellman.generateKeys([encoding])
@ -518,28 +518,28 @@ Returns the Diffie-Hellman public key in the specified `encoding`, which
can be `'latin1'` , `'hex'` , or `'base64'` . If `encoding` is provided a
can be `'latin1'` , `'hex'` , or `'base64'` . If `encoding` is provided a
string is returned; otherwise a [`Buffer`][] is returned.
string is returned; otherwise a [`Buffer`][] is returned.
### diffieHellman.setPrivateKey(private_k ey[, encoding])
### diffieHellman.setPrivateKey(privateK ey[, encoding])
<!-- YAML
<!-- YAML
added: v0.5.0
added: v0.5.0
-->
-->
- `private_k ey` {string | Buffer | TypedArray | DataView}
- `privateK ey` {string | Buffer | TypedArray | DataView}
- `encoding` {string}
- `encoding` {string}
Sets the Diffie-Hellman private key. If the `encoding` argument is provided
Sets the Diffie-Hellman private key. If the `encoding` argument is provided
and is either `'latin1'` , `'hex'` , or `'base64'` , `private_k ey` is expected
and is either `'latin1'` , `'hex'` , or `'base64'` , `privateK ey` is expected
to be a string. If no `encoding` is provided, `private_k ey` is expected
to be a string. If no `encoding` is provided, `privateK ey` is expected
to be a [`Buffer`][], `TypedArray` , or `DataView` .
to be a [`Buffer`][], `TypedArray` , or `DataView` .
### diffieHellman.setPublicKey(public_k ey[, encoding])
### diffieHellman.setPublicKey(publicK ey[, encoding])
<!-- YAML
<!-- YAML
added: v0.5.0
added: v0.5.0
-->
-->
- `public_k ey` {string | Buffer | TypedArray | DataView}
- `publicK ey` {string | Buffer | TypedArray | DataView}
- `encoding` {string}
- `encoding` {string}
Sets the Diffie-Hellman public key. If the `encoding` argument is provided
Sets the Diffie-Hellman public key. If the `encoding` argument is provided
and is either `'latin1'` , `'hex'` or `'base64'` , `public_k ey` is expected
and is either `'latin1'` , `'hex'` or `'base64'` , `publicK ey` is expected
to be a string. If no `encoding` is provided, `public_k ey` is expected
to be a string. If no `encoding` is provided, `publicK ey` is expected
to be a [`Buffer`][], `TypedArray` , or `DataView` .
to be a [`Buffer`][], `TypedArray` , or `DataView` .
### diffieHellman.verifyError
### diffieHellman.verifyError
@ -589,27 +589,27 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
// OK
// OK
```
```
### ecdh.computeSecret(other_public_key[, input_encoding][, output_e ncoding])
### ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputE ncoding])
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `other_public_k ey` {string | Buffer | TypedArray | DataView}
- `otherPublicK ey` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
- `output_e ncoding` {string}
- `outputE ncoding` {string}
Computes the shared secret using `other_public_k ey` as the other
Computes the shared secret using `otherPublicK ey` as the other
party's public key and returns the computed shared secret. The supplied
party's public key and returns the computed shared secret. The supplied
key is interpreted using specified `input_e ncoding` , and the returned secret
key is interpreted using specified `inputE ncoding` , and the returned secret
is encoded using the specified `output_e ncoding` . Encodings can be
is encoded using the specified `outputE ncoding` . Encodings can be
`'latin1'` , `'hex'` , or `'base64'` . If the `input_e ncoding` is not
`'latin1'` , `'hex'` , or `'base64'` . If the `inputE ncoding` is not
provided, `other_public_k ey` is expected to be a [`Buffer`][], `TypedArray` , or
provided, `otherPublicK ey` is expected to be a [`Buffer`][], `TypedArray` , or
`DataView` .
`DataView` .
If `output_e ncoding` is given a string will be returned; otherwise a
If `outputE ncoding` is given a string will be returned; otherwise a
[`Buffer`][] is returned.
[`Buffer`][] is returned.
### ecdh.generateKeys([encoding[, format]])
### ecdh.generateKeys([encoding[, format]])
@ -659,23 +659,23 @@ The `encoding` argument can be `'latin1'`, `'hex'`, or `'base64'`. If
`encoding` is specified, a string is returned; otherwise a [`Buffer`][] is
`encoding` is specified, a string is returned; otherwise a [`Buffer`][] is
returned.
returned.
### ecdh.setPrivateKey(private_k ey[, encoding])
### ecdh.setPrivateKey(privateK ey[, encoding])
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
-->
-->
- `private_k ey` {string | Buffer | TypedArray | DataView}
- `privateK ey` {string | Buffer | TypedArray | DataView}
- `encoding` {string}
- `encoding` {string}
Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'` ,
Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'` ,
`'hex'` or `'base64'` . If `encoding` is provided, `private_k ey` is expected
`'hex'` or `'base64'` . If `encoding` is provided, `privateK ey` is expected
to be a string; otherwise `private_k ey` is expected to be a [`Buffer`][],
to be a string; otherwise `privateK ey` is expected to be a [`Buffer`][],
`TypedArray` , or `DataView` .
`TypedArray` , or `DataView` .
If `private_k ey` is not valid for the curve specified when the `ECDH` object was
If `privateK ey` is not valid for the curve specified when the `ECDH` object was
created, an error is thrown. Upon setting the private key, the associated
created, an error is thrown. Upon setting the private key, the associated
public point (key) is also generated and set in the ECDH object.
public point (key) is also generated and set in the ECDH object.
### ecdh.setPublicKey(public_k ey[, encoding])
### ecdh.setPublicKey(publicK ey[, encoding])
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
deprecated: v5.2.0
deprecated: v5.2.0
@ -683,11 +683,11 @@ deprecated: v5.2.0
> Stability: 0 - Deprecated
> Stability: 0 - Deprecated
- `public_k ey` {string | Buffer | TypedArray | DataView}
- `publicK ey` {string | Buffer | TypedArray | DataView}
- `encoding` {string}
- `encoding` {string}
Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'` ,
Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'` ,
`'hex'` or `'base64'` . If `encoding` is provided `public_k ey` is expected to
`'hex'` or `'base64'` . If `encoding` is provided `publicK ey` is expected to
be a string; otherwise a [`Buffer`][], `TypedArray` , or `DataView` is expected.
be a string; otherwise a [`Buffer`][], `TypedArray` , or `DataView` is expected.
Note that there is not normally a reason to call this method because `ECDH`
Note that there is not normally a reason to call this method because `ECDH`
@ -793,22 +793,22 @@ a [`Buffer`][] is returned.
The `Hash` object can not be used again after `hash.digest()` method has been
The `Hash` object can not be used again after `hash.digest()` method has been
called. Multiple calls will cause an error to be thrown.
called. Multiple calls will cause an error to be thrown.
### hash.update(data[, input_e ncoding])
### hash.update(data[, inputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.92
added: v0.1.92
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
Updates the hash content with the given `data` , the encoding of which
Updates the hash content with the given `data` , the encoding of which
is given in `input_e ncoding` and can be `'utf8'` , `'ascii'` or
is given in `inputE ncoding` and can be `'utf8'` , `'ascii'` or
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
`DataView` , then `input_e ncoding` is ignored.
`DataView` , then `inputE ncoding` is ignored.
This can be called many times with new data as it is streamed.
This can be called many times with new data as it is streamed.
@ -882,22 +882,22 @@ provided a string is returned; otherwise a [`Buffer`][] is returned;
The `Hmac` object can not be used again after `hmac.digest()` has been
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.
called. Multiple calls to `hmac.digest()` will result in an error being thrown.
### hmac.update(data[, input_e ncoding])
### hmac.update(data[, inputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.94
added: v0.1.94
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
Updates the `Hmac` content with the given `data` , the encoding of which
Updates the `Hmac` content with the given `data` , the encoding of which
is given in `input_e ncoding` and can be `'utf8'` , `'ascii'` or
is given in `inputE ncoding` and can be `'utf8'` , `'ascii'` or
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
`DataView` , then `input_e ncoding` is ignored.
`DataView` , then `inputE ncoding` is ignored.
This can be called many times with new data as it is streamed.
This can be called many times with new data as it is streamed.
@ -967,7 +967,7 @@ pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==
console.log(sign.sign(privateKey).toString('hex'));
console.log(sign.sign(privateKey).toString('hex'));
```
```
### sign.sign(private_key[, output_f ormat])
### sign.sign(privateKey[, outputF ormat])
<!-- YAML
<!-- YAML
added: v0.1.92
added: v0.1.92
changes:
changes:
@ -975,16 +975,16 @@ changes:
pr-url: https://github.com/nodejs/node/pull/11705
pr-url: https://github.com/nodejs/node/pull/11705
description: Support for RSASSA-PSS and additional options was added.
description: Support for RSASSA-PSS and additional options was added.
-->
-->
- `private_k ey` {string | Object}
- `privateK ey` {string | Object}
- `key` {string}
- `key` {string}
- `passphrase` {string}
- `passphrase` {string}
- `output_f ormat` {string}
- `outputF ormat` {string}
Calculates the signature on all the data passed through using either
Calculates the signature on all the data passed through using either
[`sign.update()`][] or [`sign.write()`][stream-writable-write].
[`sign.update()`][] or [`sign.write()`][stream-writable-write].
The `private_key` argument can be an object or a string. If `private_k ey` is a
The `privateKey` argument can be an object or a string. If `privateK ey` is a
string, it is treated as a raw key with no passphrase. If `private_k ey` is an
string, it is treated as a raw key with no passphrase. If `privateK ey` is an
object, it must contain one or more of the following properties:
object, it must contain one or more of the following properties:
* `key` : {string} - PEM encoded private key (required)
* `key` : {string} - PEM encoded private key (required)
@ -1001,29 +1001,29 @@ object, it must contain one or more of the following properties:
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
maximum permissible value.
maximum permissible value.
The `output_f ormat` can specify one of `'latin1'` , `'hex'` or `'base64'` . If
The `outputF ormat` can specify one of `'latin1'` , `'hex'` or `'base64'` . If
`output_f ormat` is provided a string is returned; otherwise a [`Buffer`][] is
`outputF ormat` is provided a string is returned; otherwise a [`Buffer`][] is
returned.
returned.
The `Sign` object can not be again used after `sign.sign()` method has been
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.
called. Multiple calls to `sign.sign()` will result in an error being thrown.
### sign.update(data[, input_e ncoding])
### sign.update(data[, inputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.92
added: v0.1.92
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
Updates the `Sign` content with the given `data` , the encoding of which
Updates the `Sign` content with the given `data` , the encoding of which
is given in `input_e ncoding` and can be `'utf8'` , `'ascii'` or
is given in `inputE ncoding` and can be `'utf8'` , `'ascii'` or
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
`DataView` , then `input_e ncoding` is ignored.
`DataView` , then `inputE ncoding` is ignored.
This can be called many times with new data as it is streamed.
This can be called many times with new data as it is streamed.
@ -1072,26 +1072,26 @@ console.log(verify.verify(publicKey, signature));
// Prints: true or false
// Prints: true or false
```
```
### verifier.update(data[, input_e ncoding])
### verifier.update(data[, inputE ncoding])
<!-- YAML
<!-- YAML
added: v0.1.92
added: v0.1.92
changes:
changes:
- version: v6.0.0
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_e ncoding` changed from `binary` to `utf8` .
description: The default `inputE ncoding` changed from `binary` to `utf8` .
-->
-->
- `data` {string | Buffer | TypedArray | DataView}
- `data` {string | Buffer | TypedArray | DataView}
- `input_e ncoding` {string}
- `inputE ncoding` {string}
Updates the `Verify` content with the given `data` , the encoding of which
Updates the `Verify` content with the given `data` , the encoding of which
is given in `input_e ncoding` and can be `'utf8'` , `'ascii'` or
is given in `inputE ncoding` and can be `'utf8'` , `'ascii'` or
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
`'latin1'` . If `encoding` is not provided, and the `data` is a string, an
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray` , or
`DataView` , then `input_e ncoding` is ignored.
`DataView` , then `inputE ncoding` is ignored.
This can be called many times with new data as it is streamed.
This can be called many times with new data as it is streamed.
### verifier.verify(object, signature[, signature_f ormat])
### verifier.verify(object, signature[, signatureF ormat])
<!-- YAML
<!-- YAML
added: v0.1.92
added: v0.1.92
changes:
changes:
@ -1101,7 +1101,7 @@ changes:
-->
-->
- `object` {string | Object}
- `object` {string | Object}
- `signature` {string | Buffer | TypedArray | DataView}
- `signature` {string | Buffer | TypedArray | DataView}
- `signature_f ormat` {string}
- `signatureF ormat` {string}
Verifies the provided data using the given `object` and `signature` .
Verifies the provided data using the given `object` and `signature` .
The `object` argument can be either a string containing a PEM encoded object,
The `object` argument can be either a string containing a PEM encoded object,
@ -1122,8 +1122,8 @@ or an object with one or more of the following properties:
determined automatically.
determined automatically.
The `signature` argument is the previously calculated signature for the data, in
The `signature` argument is the previously calculated signature for the data, in
the `signature_f ormat` which can be `'latin1'` , `'hex'` or `'base64'` .
the `signatureF ormat` which can be `'latin1'` , `'hex'` or `'base64'` .
If a `signature_f ormat` is specified, the `signature` is expected to be a
If a `signatureF ormat` is specified, the `signature` is expected to be a
string; otherwise `signature` is expected to be a [`Buffer`][],
string; otherwise `signature` is expected to be a [`Buffer`][],
`TypedArray` , or `DataView` .
`TypedArray` , or `DataView` .
@ -1273,7 +1273,7 @@ The `key` is the raw key used by the `algorithm` and `iv` is an
[initialization vector][]. Both arguments must be `'utf8'` encoded strings or
[initialization vector][]. Both arguments must be `'utf8'` encoded strings or
[buffers][`Buffer`].
[buffers][`Buffer`].
### crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_e ncoding])
### crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorE ncoding])
<!-- YAML
<!-- YAML
added: v0.11.12
added: v0.11.12
changes:
changes:
@ -1289,9 +1289,9 @@ changes:
from `binary` to `utf8` .
from `binary` to `utf8` .
-->
-->
- `prime` {string | Buffer | TypedArray | DataView}
- `prime` {string | Buffer | TypedArray | DataView}
- `prime_e ncoding` {string}
- `primeE ncoding` {string}
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2` .
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2` .
- `generator_e ncoding` {string}
- `generatorE ncoding` {string}
Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
optional specific `generator` .
optional specific `generator` .
@ -1299,34 +1299,34 @@ optional specific `generator`.
The `generator` argument can be a number, string, or [`Buffer`][]. If
The `generator` argument can be a number, string, or [`Buffer`][]. If
`generator` is not specified, the value `2` is used.
`generator` is not specified, the value `2` is used.
The `prime_encoding` and `generator_e ncoding` arguments can be `'latin1'` ,
The `primeEncoding` and `generatorE ncoding` arguments can be `'latin1'` ,
`'hex'` , or `'base64'` .
`'hex'` , or `'base64'` .
If `prime_e ncoding` is specified, `prime` is expected to be a string; otherwise
If `primeE ncoding` is specified, `prime` is expected to be a string; otherwise
a [`Buffer`][], `TypedArray` , or `DataView` is expected.
a [`Buffer`][], `TypedArray` , or `DataView` is expected.
If `generator_e ncoding` is specified, `generator` is expected to be a string;
If `generatorE ncoding` is specified, `generator` is expected to be a string;
otherwise a number, [`Buffer`][], `TypedArray` , or `DataView` is expected.
otherwise a number, [`Buffer`][], `TypedArray` , or `DataView` is expected.
### crypto.createDiffieHellman(prime_l ength[, generator])
### crypto.createDiffieHellman(primeL ength[, generator])
<!-- YAML
<!-- YAML
added: v0.5.0
added: v0.5.0
-->
-->
- `prime_l ength` {number}
- `primeL ength` {number}
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2` .
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2` .
Creates a `DiffieHellman` key exchange object and generates a prime of
Creates a `DiffieHellman` key exchange object and generates a prime of
`prime_l ength` bits using an optional specific numeric `generator` .
`primeL ength` bits using an optional specific numeric `generator` .
If `generator` is not specified, the value `2` is used.
If `generator` is not specified, the value `2` is used.
### crypto.createECDH(curve_n ame)
### crypto.createECDH(curveN ame)
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
-->
-->
- `curve_n ame` {string}
- `curveN ame` {string}
Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
predefined curve specified by the `curve_n ame` string. Use
predefined curve specified by the `curveN ame` string. Use
[`crypto.getCurves()`][] to obtain a list of available curve names. On recent
[`crypto.getCurves()`][] to obtain a list of available curve names. On recent
OpenSSL releases, `openssl ecparam -list_curves` will also display the name
OpenSSL releases, `openssl ecparam -list_curves` will also display the name
and description of each available elliptic curve.
and description of each available elliptic curve.
@ -1449,11 +1449,11 @@ const curves = crypto.getCurves();
console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
```
```
### crypto.getDiffieHellman(group_n ame)
### crypto.getDiffieHellman(groupN ame)
<!-- YAML
<!-- YAML
added: v0.7.5
added: v0.7.5
-->
-->
- `group_n ame` {string}
- `groupN ame` {string}
Creates a predefined `DiffieHellman` key exchange object. The
Creates a predefined `DiffieHellman` key exchange object. The
supported groups are: `'modp1'` , `'modp2'` , `'modp5'` (defined in
supported groups are: `'modp1'` , `'modp2'` , `'modp5'` (defined in
@ -1599,11 +1599,11 @@ console.log(key.toString('hex')); // '3745e48...aa39b34'
An array of supported digest functions can be retrieved using
An array of supported digest functions can be retrieved using
[`crypto.getHashes()`][].
[`crypto.getHashes()`][].
### crypto.privateDecrypt(private_k ey, buffer)
### crypto.privateDecrypt(privateK ey, buffer)
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
-->
-->
- `private_k ey` {Object | string}
- `privateK ey` {Object | string}
- `key` {string} A PEM encoded private key.
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
- `padding` {crypto.constants} An optional padding value defined in
@ -1611,16 +1611,16 @@ added: v0.11.14
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
- `buffer` {Buffer | TypedArray | DataView}
- `buffer` {Buffer | TypedArray | DataView}
Decrypts `buffer` with `private_k ey` .
Decrypts `buffer` with `privateK ey` .
`private_key` can be an object or a string. If `private_k ey` is a string, it is
`privateKey` can be an object or a string. If `privateK ey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING` .
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING` .
### crypto.privateEncrypt(private_k ey, buffer)
### crypto.privateEncrypt(privateK ey, buffer)
<!-- YAML
<!-- YAML
added: v1.1.0
added: v1.1.0
-->
-->
- `private_k ey` {Object | string}
- `privateK ey` {Object | string}
- `key` {string} A PEM encoded private key.
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
- `padding` {crypto.constants} An optional padding value defined in
@ -1628,16 +1628,16 @@ added: v1.1.0
`RSA_PKCS1_PADDING` .
`RSA_PKCS1_PADDING` .
- `buffer` {Buffer | TypedArray | DataView}
- `buffer` {Buffer | TypedArray | DataView}
Encrypts `buffer` with `private_k ey` .
Encrypts `buffer` with `privateK ey` .
`private_key` can be an object or a string. If `private_k ey` is a string, it is
`privateKey` can be an object or a string. If `privateK ey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING` .
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING` .
### crypto.publicDecrypt(public_k ey, buffer)
### crypto.publicDecrypt(publicK ey, buffer)
<!-- YAML
<!-- YAML
added: v1.1.0
added: v1.1.0
-->
-->
- `public_k ey` {Object | string}
- `publicK ey` {Object | string}
- `key` {string} A PEM encoded private key.
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
- `padding` {crypto.constants} An optional padding value defined in
@ -1645,19 +1645,19 @@ added: v1.1.0
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
- `buffer` {Buffer | TypedArray | DataView}
- `buffer` {Buffer | TypedArray | DataView}
Decrypts `buffer` with `public_k ey` .
Decrypts `buffer` with `publicK ey` .
`public_key` can be an object or a string. If `public_k ey` is a string, it is
`publicKey` can be an object or a string. If `publicK ey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING` .
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING` .
Because RSA public keys can be derived from private keys, a private key may
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.
be passed instead of a public key.
### crypto.publicEncrypt(public_k ey, buffer)
### crypto.publicEncrypt(publicK ey, buffer)
<!-- YAML
<!-- YAML
added: v0.11.14
added: v0.11.14
-->
-->
- `public_k ey` {Object | string}
- `publicK ey` {Object | string}
- `key` {string} A PEM encoded private key.
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
- `padding` {crypto.constants} An optional padding value defined in
@ -1665,10 +1665,10 @@ added: v0.11.14
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
`RSA_PKCS1_PADDING` , or `crypto.constants.RSA_PKCS1_OAEP_PADDING` .
- `buffer` {Buffer | TypedArray | DataView}
- `buffer` {Buffer | TypedArray | DataView}
Encrypts the content of `buffer` with `public_k ey` and returns a new
Encrypts the content of `buffer` with `publicK ey` and returns a new
[`Buffer`][] with encrypted content.
[`Buffer`][] with encrypted content.
`public_key` can be an object or a string. If `public_k ey` is a string, it is
`publicKey` can be an object or a string. If `publicK ey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING` .
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING` .
Because RSA public keys can be derived from private keys, a private key may
Because RSA public keys can be derived from private keys, a private key may
@ -2201,14 +2201,14 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
[`Buffer`]: buffer.html
[`Buffer`]: buffer.html
[`EVP_BytesToKey`]: https://www.openssl.org/docs/man1.0.2/crypto/EVP_BytesToKey.html
[`EVP_BytesToKey`]: https://www.openssl.org/docs/man1.0.2/crypto/EVP_BytesToKey.html
[`cipher.final()`]: #crypto_cipher_final_output_ encoding
[`cipher.final()`]: #crypto_cipher_final_outputencoding
[`cipher.update()`]: #crypto_cipher_update_data_input_ encoding_output_ encoding
[`cipher.update()`]: #crypto_cipher_update_data_inputencoding_outputencoding
[`crypto.createCipher()`]: #crypto_crypto_createcipher_algorithm_password
[`crypto.createCipher()`]: #crypto_crypto_createcipher_algorithm_password
[`crypto.createCipheriv()`]: #crypto_crypto_createcipheriv_algorithm_key_iv
[`crypto.createCipheriv()`]: #crypto_crypto_createcipheriv_algorithm_key_iv
[`crypto.createDecipher()`]: #crypto_crypto_createdecipher_algorithm_password
[`crypto.createDecipher()`]: #crypto_crypto_createdecipher_algorithm_password
[`crypto.createDecipheriv()`]: #crypto_crypto_createdecipheriv_algorithm_key_iv
[`crypto.createDecipheriv()`]: #crypto_crypto_createdecipheriv_algorithm_key_iv
[`crypto.createDiffieHellman()`]: #crypto_crypto_creatediffiehellman_prime_prime_ encoding_generator_generator_ encoding
[`crypto.createDiffieHellman()`]: #crypto_crypto_creatediffiehellman_prime_primeencoding_generator_generatorencoding
[`crypto.createECDH()`]: #crypto_crypto_createecdh_curve_ name
[`crypto.createECDH()`]: #crypto_crypto_createecdh_curvename
[`crypto.createHash()`]: #crypto_crypto_createhash_algorithm
[`crypto.createHash()`]: #crypto_crypto_createhash_algorithm
[`crypto.createHmac()`]: #crypto_crypto_createhmac_algorithm_key
[`crypto.createHmac()`]: #crypto_crypto_createhmac_algorithm_key
[`crypto.createSign()`]: #crypto_crypto_createsign_algorithm
[`crypto.createSign()`]: #crypto_crypto_createsign_algorithm
@ -2218,21 +2218,21 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
[`crypto.pbkdf2()`]: #crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback
[`crypto.pbkdf2()`]: #crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback
[`crypto.randomBytes()`]: #crypto_crypto_randombytes_size_callback
[`crypto.randomBytes()`]: #crypto_crypto_randombytes_size_callback
[`crypto.randomFill()`]: #crypto_crypto_randomfill_buffer_offset_size_callback
[`crypto.randomFill()`]: #crypto_crypto_randomfill_buffer_offset_size_callback
[`decipher.final()`]: #crypto_decipher_final_output_ encoding
[`decipher.final()`]: #crypto_decipher_final_outputencoding
[`decipher.update()`]: #crypto_decipher_update_data_input_ encoding_output_ encoding
[`decipher.update()`]: #crypto_decipher_update_data_inputencoding_outputencoding
[`diffieHellman.setPublicKey()`]: #crypto_diffiehellman_setpublickey_public_ key_encoding
[`diffieHellman.setPublicKey()`]: #crypto_diffiehellman_setpublickey_publickey_encoding
[`ecdh.generateKeys()`]: #crypto_ecdh_generatekeys_encoding_format
[`ecdh.generateKeys()`]: #crypto_ecdh_generatekeys_encoding_format
[`ecdh.setPrivateKey()`]: #crypto_ecdh_setprivatekey_private_ key_encoding
[`ecdh.setPrivateKey()`]: #crypto_ecdh_setprivatekey_privatekey_encoding
[`ecdh.setPublicKey()`]: #crypto_ecdh_setpublickey_public_ key_encoding
[`ecdh.setPublicKey()`]: #crypto_ecdh_setpublickey_publickey_encoding
[`hash.digest()`]: #crypto_hash_digest_encoding
[`hash.digest()`]: #crypto_hash_digest_encoding
[`hash.update()`]: #crypto_hash_update_data_input_ encoding
[`hash.update()`]: #crypto_hash_update_data_inputencoding
[`hmac.digest()`]: #crypto_hmac_digest_encoding
[`hmac.digest()`]: #crypto_hmac_digest_encoding
[`hmac.update()`]: #crypto_hmac_update_data_input_ encoding
[`hmac.update()`]: #crypto_hmac_update_data_inputencoding
[`sign.sign()`]: #crypto_sign_sign_private_ key_output_ format
[`sign.sign()`]: #crypto_sign_sign_privatekey_outputformat
[`sign.update()`]: #crypto_sign_update_data_input_ encoding
[`sign.update()`]: #crypto_sign_update_data_inputencoding
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
[`verify.update()`]: #crypto_verifier_update_data_input_ encoding
[`verify.update()`]: #crypto_verifier_update_data_inputencoding
[`verify.verify()`]: #crypto_verifier_verify_object_signature_signature_ format
[`verify.verify()`]: #crypto_verifier_verify_object_signature_signatureformat
[Caveats]: #crypto_support_for_weak_or_compromised_algorithms
[Caveats]: #crypto_support_for_weak_or_compromised_algorithms
[Crypto Constants]: #crypto_crypto_constants_1
[Crypto Constants]: #crypto_crypto_constants_1
[HTML5's `keygen` element]: http://www.w3.org/TR/html5/forms.html#the-keygen-element
[HTML5's `keygen` element]: http://www.w3.org/TR/html5/forms.html#the-keygen-element