An Argon2 library for Node
npm install argon2-native[![Build status][actions-image]][actions-url]
[![NPM package][npm-image]][npm-url]
This is a fork of ranisalt/node-argon2 using node 24's crypto.argon2() instead of libargon2.
node-argon2- Published as both cjs and mjs.
- This means you can import argon2 instead of import * as argon2
- Written in typescript instead of javascript with jsdoc.
- Node's argon2 implementation does not expose version so this is not configurable.
needsRehash will always return true if a version is specified in the digest.
- options.type is now a string instead of an enum:
``diff`
hash('password', {
- type: argon2.argon2d
+ type: 'argon2d'
})
To hash a password:
`js
import argon2 from 'argon2-native'
try {
const hash = await argon2.hash('password')
} catch (err) {
//...
}
`
To see how you can modify the output (hash length, encoding) and parameters
(time cost, memory cost and parallelism),
read the wiki
To verify a password:
`js`
try {
if (await argon2.verify('', 'password')) {
// password match
} else {
// password did not match
}
} catch (err) {
// internal failure
}
`ts
import argon2 from 'argon2-native'
const hash = await argon2.hash(...)
``
This project exists thanks to all the people who contribute. [Contribute].
Become a financial contributor and help us sustain our community. [Contribute]
#### Individuals
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
[opencollective-image]: https://img.shields.io/opencollective/all/node-argon2.svg?style=flat-square
[opencollective-url]: https://opencollective.com/node-argon2
[npm-image]: https://img.shields.io/npm/v/argon2-native.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/argon2-native
[actions-image]: https://img.shields.io/github/actions/workflow/status/kaelwd/node-argon2/ci.yml?branch=master&style=flat-square
[actions-url]: https://github.com/kaelwd/node-argon2/actions