Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Adding best practises for crypto.pbkdf2 #3290

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/api/crypto.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,16 @@ Asynchronous PBKDF2 function. Applies the selected HMAC digest function
salt and number of iterations. The callback gets two arguments:
`(err, derivedKey)`.

The number of iterations passed to pbkdf2 should be as high as possible, the
higher the number, the more secure it will be, but will take a longer amount of
time to complete.

Chosen salts should also be unique. It is recommended that the salts are random
and their length is greater than 16 bytes. See NIST 800-132 for details.

Example:

crypto.pbkdf2('secret', 'salt', 4096, 64, 'sha256', function(err, key) {
crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', function(err, key) {
if (err)
throw err;
console.log(key.toString('hex')); // 'c5e478d...1469e50'
Expand Down