You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

argon2

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
n

argon2

An Argon2 library for Node

0.43.1
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

86

Maintenance

100

License

Version published
Weekly downloads
286K
-19.77%
Maintainers
1
Weekly downloads
 
Created
Issues
2

What is argon2?

The argon2 npm package is a library for hashing passwords using the Argon2 algorithm, which is a modern, secure, and memory-hard hashing algorithm. It is designed to be resistant to GPU cracking attacks and is considered one of the most secure password hashing algorithms available.

What are argon2's main functionalities?

Hashing a password

This feature allows you to hash a password using the Argon2 algorithm. The hash function takes a plain text password and returns a hashed version of it.

const argon2 = require('argon2');
(async () => {
  try {
    const hash = await argon2.hash('password');
    console.log(hash);
  } catch (err) {
    console.error(err);
  }
})();

Verifying a password

This feature allows you to verify a password against a previously hashed password. The verify function takes a hash and a plain text password and returns a boolean indicating whether the password matches the hash.

const argon2 = require('argon2');
(async () => {
  try {
    const hash = await argon2.hash('password');
    const isMatch = await argon2.verify(hash, 'password');
    console.log(isMatch); // true
  } catch (err) {
    console.error(err);
  }
})();

Configuring hashing options

This feature allows you to configure various options for the hashing process, such as the type of Argon2 algorithm to use (argon2d, argon2i, or argon2id), memory cost, time cost, and parallelism.

const argon2 = require('argon2');
(async () => {
  try {
    const hash = await argon2.hash('password', {
      type: argon2.argon2id,
      memoryCost: 2 ** 16,
      timeCost: 5,
      parallelism: 1
    });
    console.log(hash);
  } catch (err) {
    console.error(err);
  }
})();

Other packages similar to argon2

FAQs

Package last updated on 14 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts