bcrypt.js

A zero-dependency, pure JavaScript implementation of bcrypt for hashing and verifying passwords in Node.js and the browser.

Library
npm
v3.0.3
3,796stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity36
Maintenance20
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture72
Code Quality68
Innovation70
Learning Curve85

bcryptjs is a pure JavaScript port of the bcrypt password-hashing algorithm, built to be a drop-in, dependency-free alternative to the native C++ bcrypt binding for Node.js. It works anywhere JavaScript runs, including browsers, by relying on the Web Crypto API or Node’s crypto module for secure randomness, with a pluggable fallback for other environments.

The library exposes both synchronous and asynchronous (promise or callback-based) APIs for generating salts, hashing passwords, and comparing hashes, while remaining wire-compatible with hashes produced by the original bcrypt implementation. Because it ships as an ECMAScript module with a UMD fallback and TypeScript type definitions, it drops into modern bundlers, older CommonJS projects, and browser-only builds without a native compilation step.

What You Get

  • Synchronous and asynchronous APIs (hashSync/hash, compareSync/compare) supporting promises or Node-style callbacks
  • Configurable salt generation via genSalt/genSaltSync with an adjustable cost factor (rounds)
  • Zero runtime dependencies, with automatic use of the Web Crypto API or Node’s crypto module for secure random bytes, plus a setRandomFallback hook for constrained environments
  • Cross-format compatibility, correctly hashing and comparing against $2a$, $2b$, and $2y$ prefixed hashes produced by other bcrypt implementations
  • TypeScript type declarations and both ESM and UMD builds for use in Node.js, bundlers, and directly in browsers
  • A small CLI (bcrypt <input> [rounds|salt]) for quick command-line hashing

Common Use Cases

  • Hashing user passwords before storing them in a database during signup or password-change flows
  • Verifying a submitted login password against a stored bcrypt hash
  • Hashing credentials in browser-based or edge/serverless environments where native Node.js addons aren’t available
  • Replacing the native bcrypt package in projects where native compilation (node-gyp) is problematic in CI or deployment

Under The Hood

Architecture — The entire library lives in a single ~1,150-line index.js module (Blowfish cipher core, base64 codec using bcrypt’s custom alphabet, and the public salt/hash/compare API) with no internal package boundaries; execution flows from genSalt(Sync) (builds a $2b$<rounds>$<salt> string using randomBytes, sourced from the Web Crypto API with a Node crypto fallback and a user-settable setRandomFallback) into hash(Sync)/compare(Sync), which run the Blowfish-based Eksblowfish key schedule directly in JS; async variants chunk the round computation and yield to the event loop via MAX_EXECUTION_TIME-bounded slices with an optional ProgressCallback, avoiding blocking Node’s single thread on high cost factors. Tech Stack — Zero runtime dependencies; the module is authored as a native ES module ("type": "module") with a companion umd/ build generated at publish time by scripts/build.js via the esm2umd transpiler and reformatted with Prettier, giving consumers both an ESM entry (index.js) and a UMD/CommonJS entry (umd/index.js) plus hand-maintained .d.ts type declarations (types.d.ts) copied into both output paths; a bin/bcrypt script exposes the same API as a one-off CLI. Code Qualitytests/index.js is a flat array of self-registered test functions (no framework) that assert against assert/assert.strictEqual/assert.deepEqual, including a cross-check against the native bcrypt npm package (bcrypt-nodejs/C++ binding) as a devDependency to confirm hash format and comparison compatibility across $2a$, $2b$, and $2y$ prefixes; there is no formal linter beyond Prettier --check, and the source relies on var-based ES5-style internals despite being distributed as ESM, reflecting its long maintenance history since 2013. API Design — The public surface intentionally mirrors the native Node bcrypt package’s function names and call signatures (hashSync, hash, compareSync, compare, genSalt(Sync)) so it acts as a drop-in substitute, supports both promise-based and Node-style callback usage on every async function, and documents defaults (10 rounds) so most callers can call bcrypt.hash(password, 10) with no further configuration.

Used by 49 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
96%
Other

CapRover

Developer Tools · Devops · Hosting Control Panel

15,132

Deploy any app, database, or website to your own server in minutes—no Docker or Linux expertise required.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript96%
Updated 3 days ago
TypeScript
97%
AGPL 3.0

Checkmate

Devops · Analytics · Monitoring

10,556

Self-hosted uptime and infrastructure monitoring with multi-protocol checks, global geo-coverage, and beautiful real-time dashboards.

View details
91
Repo Health
82
Technical
69
Dependency
Built with
TypeScript97%
Updated yesterday
JavaScript
53%
Other

Cosmos-Server

Security · Authentication

6,121

All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.

View details
79
Repo Health
59
Technical
66
Dependency
Built with
JavaScript53%
Go43%
Updated yesterday
TypeScript
100%
Other

Dub

Marketing · Analytics

24,521

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
81
Repo Health
78
Technical
65
Dependency
Built with
TypeScript100%
Updated today
TypeScript
95%
Apache 2.0

Enclosed

Security

2,060

Send end-to-end encrypted notes and files where the server never sees your content — true zero-knowledge sharing.

View details
57
Repo Health
88
Technical
71
Dependency
Built with
TypeScript95%
Updated 5 days 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