Skip to content

Commit

Permalink
Use callback randomBytes for callback argon2
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed Oct 26, 2023
1 parent eb235ee commit feb134d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2905,7 +2905,7 @@ This property is deprecated. Please use `crypto.setFips()` and
### `crypto.argon2(password, salt, keylen[, options], callback)`

<!-- YAML
added: v21.0.0
added: REPLACEME
-->

* `password` {string|ArrayBuffer|Buffer|TypedArray|DataView}
Expand Down Expand Up @@ -2969,23 +2969,28 @@ const {
randomBytes,
} = require('node:crypto');

const salt = randomBytes(16);
// Using the factory defaults.
argon2('password', salt, 64, (err, derivedKey) => {
randomBytes(16, (err, salt) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '0de3036...22afcc5'
argon2('password', salt, 64, (err, derivedKey) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '0de3036...22afcc5'
});
});
// Using a custom iter parameter.
argon2('password', salt, 64, { iter: 3 }, (err, derivedKey) => {
randomBytes(16, (err, salt) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '0de3036...22afcc5'
argon2('password', salt, 64, { iter: 3 }, (err, derivedKey) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '0de3036...22afcc5'
});
});
```

### `crypto.argon2Sync(password, salt, keylen[, options])`

<!-- YAML
added: v21.0.0
added: REPLACEME
-->

* `password` {string|Buffer|TypedArray|DataView}
Expand Down

0 comments on commit feb134d

Please sign in to comment.