doc: show keylen in pbkdf2 as a byte length
[platform/upstream/nodejs.git] / doc / api / crypto.markdown
index e1852ff..04d7af6 100644 (file)
@@ -323,7 +323,7 @@ called.
 
 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`.
 
@@ -621,13 +621,13 @@ Example (obtaining a shared secret):
 ## 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'
@@ -651,13 +651,8 @@ Generates cryptographically strong pseudo-random data. Usage:
     });
 
     // 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