How to use the scrypt function from crypto

Find comprehensive JavaScript crypto.scrypt code examples handpicked from public code repositorys.

159
160
161
162
163
164
165
166
167
168
169


for (const options of bad) {
  const expected = {
    message: /Invalid scrypt param/,
  };
  assert.throws(() => crypto.scrypt('pass', 'salt', 1, options, () => {}),
                expected);
  assert.throws(() => crypto.scryptSync('pass', 'salt', 1, options),
                expected);
}
fork icon42
star icon19
watch icon0

+ 21 other calls in file

15
16
17
18
19
20
21
22
23
24
25
26
    process.exit(1);
  }
};


const startCrypto = () => {
  crypto.scrypt(password, "salt", 24, (err, key) => {
    if (err) throw err;


    crypto.randomFill(new Uint8Array(16), (err, iv) => {
      if (err) throw err;
fork icon0
star icon0
watch icon0

15
16
17
18
19
20
21
22
23
24
if (typeof password != "string") { throw new TypeError("password must be a string"); };

const salt = crypto.randomBytes(256).toString('hex');

return new Promise((resolve, rejects) => {
    crypto.scrypt(password, salt, 256, (error, derivedKey) => {
        if (error) {
            rejects(error);
        };
        resolve(
fork icon0
star icon0
watch icon0