# bcryptjs — card for AI agents

Pure JavaScript bcrypt implementation for secure password hashing without dependencies.

Category: Auth and security libraries · npm package `bcryptjs` · latest version 3.0.3 (checked 2026-11-01)
Install: `npm install bcryptjs`
License: BSD-3-Clause (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## bcryptjs
- Import with `import bcrypt from "bcryptjs";`. The package exports an ES module with a UMD fallback.
- Input longer than 72 bytes in UTF-8 is truncated when hashed. The library does not check this implicitly, so call `bcrypt.truncates(password)` where necessary.
- Generated hashes are 60 characters long. Rounds default to 10 when omitted in `genSalt`, `genSaltSync` and `hashSync`.
- From a CDN, replace `TAG`/`VERSION` with a specific version. The README says omitting it to get the latest is not recommended in production.
- When using the ESM build directly in a browser, stub out the `crypto` import, for example with an import map. Bundlers should omit it automatically.
- `setRandomFallback` is only needed when neither Web Crypto nor Node.js `crypto` is available. The PRNG you pass must be cryptographically secure and seeded properly.
- `getSalt` does not validate the hash it reads from.

## What it is
- bcryptjs is a password hashing library. The README describes it as "Optimized bcrypt in JavaScript with zero dependencies, with TypeScript support." It also says the library is compatible with the C++ `bcrypt` binding on Node.js and works in the browser. The repository was created on 2013-05-01 and is BSD-3-Clause licensed. The README credits earlier work in bcrypt-nodejs, which itself was based on javascript-bcrypt.
- The API comes in two forms. The sync form has `genSaltSync`, `hashSync` and `compareSync`. The async form has `genSalt`, `hash` and `compare`, which return promises or take callbacks. The package also includes a command-line tool, `bcrypt <input> [rounds|salt]`. The latest release, v3.0.3, lists one bug fix: "Always yield to event loop before nextTick for async versions".
- The README sets out the limits up front. Input is capped at 72 bytes, and a UTF-8 character can take up to 4 bytes. Generated hashes are 60 characters long.

## Caveats
- README puts it about 30% slower: The README says the library is slower than the C++ binding because it is pure JavaScript, "about 30%" by its linked benchmark. It notes this effectively reduces the number of iterations you can process in the same time.
- Input past 72 bytes is truncated: A password longer than 72 bytes in UTF-8 is truncated when hashed. `bcrypt.truncates(password)` tells you in advance whether that will happen.
- Browser ESM needs a crypto stub: If you load the ESM build directly in a browser, you have to stub out the `crypto` import, for example with an import map. The README says bundlers should omit it automatically.
- Random fallback is your responsibility: If neither Web Crypto nor Node.js `crypto` is available, you supply random bytes through `setRandomFallback`. The README warns that this generator must be secure and properly seeded.
- getSalt does not validate: `getSalt` returns the salt portion of a hash. The README says it does not check that the hash is valid.

## Numbers (AgentGid data)
- Gid Score: 69.4 (#413 of all tools, 12 of 141 in its category)
- Used in 196 public projects set up for AI coding agents (3.1%)
- Downloads last week: 19,900,490 (as of 2026-11-24), +38.2% over 4 weeks
- GitHub stars: 3,795 (as of 2026-11-24)
- Last push: 2026-10-01

## Often used with
Next.js 70.9%, Lucide React 68.4%, React 84.7%, Tailwind CSS 81.6%, clsx 62.2%, Recharts 47.4%

## Checked alternatives (same job)
- bcrypt (JavaScript): https://agentgid.com/tools/bcrypt-npm/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/bcryptjs/
- Homepage: https://github.com/dcodeIO/bcrypt.js#readme
- Repository: https://github.com/dcodeIO/bcrypt.js
- Source: https://github.com/dcodeIO/bcrypt.js#readme
- Source: https://github.com/dcodeIO/bcrypt.js
- Source: https://github.com/dcodeIO/bcrypt.js/releases

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
