How to use the libsodium-wrappers-sumo.crypto_pwhash_MEMLIMIT_INTERACTIVE function in libsodium-wrappers-sumo

To help you get started, we’ve selected a few libsodium-wrappers-sumo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / magic / magic.js View on Github external
cb = p;
      p = null;
    }
    const done = ret(cb);

    if (!p) { return done(new Error('Cannot encrypt without a password')); }
    let sk;
    const salt = crypto.randomBytes(sodium.crypto_pwhash_SALTBYTES)

    try {
      sk = sodium.crypto_pwhash(
        KEY_SIZE,
        p,
        salt,
        sodium.crypto_pwhash_OPSLIMIT_INTERACTIVE,
        sodium.crypto_pwhash_MEMLIMIT_INTERACTIVE,
        sodium.crypto_pwhash_ALG_DEFAULT
      );
    } catch(ex) {
      return done(new Error('Libsodium error: ' +  ex))
    }

    return sync(m, Buffer.from(sk), (err, aead) => {
      const done = ret(cb);
      if (err) {
        return err;
      }
      aead.ciphertext = Buffer.concat([salt, aead.ciphertext])
      return done(null, aead);
    })
  });
};
github TankerHQ / quickstart-examples / server / src / auth.js View on Github external
const hashPassword = (password) => sodium.crypto_pwhash_str(
  password,
  sodium.crypto_pwhash_OPSLIMIT_INTERACTIVE,
  sodium.crypto_pwhash_MEMLIMIT_INTERACTIVE,
);