argon2-wasm-esm
Base on antelle/argon2-browser and canonchain/argon2-wasm, with an ES Module exporting. Just Works PERFECT with Vite.
https://github.com/P-H-C/phc-winner-argon2 compiled to base64,It works in both the NodeJS environment and the browser environment.
This project does not need to reference annoying ".wasm" files when used under the browser.
Usage
install:
npm install argon2-wasm-esm
Add script:
const argon2 = require('argon2-wasm-esm');
Get hash:
argon2
.hash({ pass: 'password', salt: 'somesalt' })
.then(h => console.log(h.hash, h.hashHex, h.encoded))
.catch(e => console.error(e.message, e.code));
Verify the encoded hash:
argon2
.verify({ pass: 'password', encoded: 'enc-hash' })
.then(() => console.log('OK'))
.catch(e => console.error(e.message, e.code));
Bring your own bundler and promise polyfill.
Other parameters:
argon2
.hash({
pass: 'password',
salt: 'salt',
time: 1,
mem: 1024,
hashLen: 24,
parallelism: 1,
type: argon2.ArgonType.Argon2d,
distPath: ''
})
.then(res => {
res.hash;
res.hashHex;
res.encoded;
})
.catch(err => {
err.message;
err.code;
});
Related Projects