argon2
Argon2 is a Node.js binding for the Argon2 password hashing algorithm, the winner of the 2015 Password Hashing Competition. Argon2 is considered the most secure…
Installation
npm install argon2
yarn add argon2
pnpm add argon2
Import
import argon2 from 'argon2';
Quick Example
import argon2 from 'argon2';
const hash = await argon2.hash('user-password', {
type: argon2.argon2id,
memoryCost: 65536,
timeCost: 3,
});
const isValid = await argon2.verify(hash, 'user-password');
console.log(isValid); // trueAbout argon2
Argon2 is a Node.js binding for the Argon2 password hashing algorithm, the winner of the 2015 Password Hashing Competition. Argon2 is considered the most secure password hashing algorithm available, designed to be resistant to GPU cracking attacks, side-channel attacks, and time-memory trade-off attacks. The algorithm has three variants: Argon2d (data-dependent, maximum resistance to GPU cracking), Argon2i (data-independent, resistant to side-channel attacks), and Argon2id (hybrid, recommended for most use cases). The Node.js library provides a simple API: argon2.hash(password) creates a hash with secure defaults, and argon2.verify(hash, password) checks a password against a stored hash. Argon2's configurable parameters include memory cost (amount of RAM used), time cost (number of iterations), and parallelism (number of threads), allowing the computational cost to be tuned precisely. The hash output is a self-describing string containing all parameters needed for verification, similar to bcrypt. Argon2 is recommended by OWASP as the primary choice for password hashing, ahead of bcrypt and scrypt. The argon2 package uses native bindings compiled through node-gyp for optimal performance.
Quick Facts
| Package | argon2 |
| Category | Auth |
| Weekly Downloads | 500K+ |
| License | MIT |
| Install | npm install argon2 |
Related Packages
bcrypt is a library for hashing passwords using the bcrypt algorithm, which is specifically designed…
Passport is the most popular authentication middleware for Node.js, providing a modular framework fo…
jsonwebtoken is the most widely used library for creating and verifying JSON Web Tokens (JWTs) in No…
jose is a universal, standards-compliant JavaScript library implementing JSON Object Signing and Enc…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.