argon2

Node.js bindings to the reference Argon2 password hashing implementation

Library
npm
v0.45.1
2,180stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
74/100Good
Development Activity72
Maintenance72
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture82
Code Quality80
Innovation76
Learning Curve85

node-argon2 exposes the reference Argon2 implementation (winner of the Password Hashing Competition) to Node.js via native bindings, so applications can hash and verify passwords with sensible, security-recommended defaults instead of hand-rolling parameters. It supports all three Argon2 variants (argon2i, argon2d, and the default argon2id) and produces PHC-formatted hash strings that embed the algorithm parameters, making stored hashes self-describing and easy to verify or upgrade later.

The library ships prebuilt native binaries for the most common OS/architecture combinations (Linux, macOS, Windows, Alpine, FreeBSD across x86-64 and ARM) so most installs avoid a local compile step, falling back to node-gyp when no matching prebuild exists. On top of hashing and verifying, it can detect whether an existing hash needs rehashing after a parameter change, and a TypeScript declaration file ships with the package for typed usage out of the box.

What You Get

  • argon2.hash() and argon2.verify() async functions with sensible, security-team-recommended defaults for memory cost, time cost, and parallelism
  • Support for all three Argon2 variants (argon2i, argon2d, argon2id) selectable via a simple type option
  • PHC-formatted output strings that embed the algorithm and parameters, so a stored hash is self-describing and portable
  • needsRehash() helper to detect when a stored hash’s parameters are out of date and should be regenerated
  • Prebuilt native binaries for Linux, macOS, Windows, Alpine, and FreeBSD across x86-64/ARM64/ARMv7, avoiding a local C++ toolchain for most users
  • Bundled TypeScript type declarations for typed usage without extra @types packages

Common Use Cases

  • Hashing user passwords at signup and verifying them at login in a Node.js backend, without hand-tuning Argon2 parameters
  • Migrating an application off bcrypt or PBKDF2 to a more modern, memory-hard hashing algorithm
  • Detecting and transparently rehashing older, weaker-parameter password hashes on next successful login via needsRehash()
  • Deriving secret material or associated-data-bound hashes for authentication tokens using Argon2’s secret/associatedData options

Under The Hood

Architecture: The published package is a thin JS wrapper (argon2.cjs) around a native N-API addon; the wrapper handles salt generation via node:crypto’s randomBytes, PHC-string serialization/deserialization via the @phc/format package, and exposes hash/verify/needsRehash as promise-returning functions built on top of the synchronous native hash binding loaded through node-gyp-build. The actual Argon2 algorithm itself lives in vendored C source under argon2/src (from the reference P-H-C/phc-winner-argon2 implementation), compiled via binding.gyp into a native addon that the JS layer calls into.

Tech Stack: JavaScript (CommonJS, type: commonjs) for the public API, C for the vendored Argon2 core, built with node-gyp/prebuildify and distributed with prebuilt .node binaries per platform via node-gyp-build at install time. Runtime dependencies are minimal: @phc/format for PHC string handling and node-addon-api/node-gyp-build for the native binding glue. The project requires Node >=22.0.0 and uses modern tooling (oxlint, oxfmt, TypeScript 7) for development.

Code Quality: test.cjs (237 lines) runs via Node’s built-in test runner and exercises hash/verify round-trips, option handling, and error paths; this is reasonably thorough for a small native-binding wrapper, though the bulk of the actual cryptographic logic lives in the vendored, separately-audited Argon2 C source rather than in this repo’s own tests. Naming is consistent and the JS wrapper is documented with JSDoc typedefs and overloads that also drive the generated TypeScript types.

API Design: The public surface is deliberately small — hash, verify, needsRehash, and a handful of named constants for the three Argon2 variants — with security-conscious defaults so most callers never need to touch tuning parameters at all. JSDoc-driven TypeScript overloads mean hash(password, {raw: true}) and the default encoded-string form are both properly typed without a separate .d.ts maintenance burden, keeping the developer experience low-friction for the common case while still exposing the full parameter set for advanced use.

Used by 6 apps in this directory

TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
JavaScript
82%
Other

Countly

Analytics · Marketing

5,887

Privacy-first, self-hosted analytics and customer engagement platform with full data ownership, GDPR compliance, and AI-powered insights across mobile, web, desktop, and IoT.

View details
96
Repo Health
82
Technical
68
Dependency
Built with
JavaScript82%
Updated today
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

37,462

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
78
Dependency
Built with
TypeScript80%
Vue18%
Updated yesterday
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
97%
Other

Infisical

Security · Devops

28,838

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
66
Dependency
Built with
TypeScript97%
Updated today
TypeScript
96%
Other

Refly

No Code Platforms · AI Development · Automation

7,490

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
66
Repo Health
76
Technical
64
Dependency
Built with
TypeScript96%
Updated 3 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search