## crypto.createCredentials(details)
- Stability: 0 - Deprecated. Use [tls.createSecureContext][] instead.
+ Stability: 0 - Deprecated: Use [tls.createSecureContext][] instead.
Creates a credentials object, with the optional details being a
dictionary with keys:
Updates the hash content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
-`'binary'`. If no encoding is provided and the input is a string an
+`'binary'`. If no encoding is provided, and the input is a string, an
encoding of `'binary'` is enforced. If `data` is a `Buffer` then
`input_encoding` is ignored.
You can disable auto padding if the data has been encrypted without
standard block padding to prevent `decipher.final` from checking and
-removing it. Can only work if the input data's length is a multiple of
+removing it. This will only work if the input data's length is a multiple of
the ciphers block size. You must call this before streaming data to
`decipher.update`.
## crypto.pbkdf2(password, salt, iterations, keylen[, digest], callback)
Asynchronous PBKDF2 function. Applies the selected HMAC digest function
-(default: SHA1) to derive a key of the requested length from the password,
+(default: SHA1) to derive a key of the requested byte length from the password,
salt and number of iterations. The callback gets two arguments:
`(err, derivedKey)`.
Example:
- crypto.pbkdf2('secret', 'salt', 4096, 512, 'sha256', function(err, key) {
+ crypto.pbkdf2('secret', 'salt', 4096, 64, 'sha256', function(err, key) {
if (err)
throw err;
console.log(key.toString('hex')); // 'c5e478d...1469e50'
});
// sync
- try {
- var buf = crypto.randomBytes(256);
- console.log('Have %d bytes of random data: %s', buf.length, buf);
- } catch (ex) {
- // handle error
- // most likely, entropy sources are drained
- }
+ const buf = crypto.randomBytes(256);
+ console.log('Have %d bytes of random data: %s', buf.length, buf);
NOTE: This will block if there is insufficient entropy, although it should
normally never take longer than a few milliseconds. The only time when this