bcrypt Generator
Free bcrypt generator and checker that hashes and verifies passwords in your browser, warns at 72 bytes, and creates htpasswd lines for Apache and nginx.
Updated
Hashed as UTF-8 exactly as typed. bcrypt uses only the first 72 bytes.
Options
4 to 31. Each step doubles the time. OWASP asks for a work factor of 10 or more on legacy systems that use bcrypt. PHP 8.4 raised its default cost from 10 to 12.
$2b$ is the prefix OpenBSD 5.5 introduced, and crypt(5) lists it as the bcrypt prefix.
A bcrypt hash, or a user:hash line from an htpasswd file.
Options
Apache htpasswd uses 5 by default and accepts 4 to 17. apr-util 1.6.0 and later enforce 17 as the maximum.
Enter a password, pick a cost, and press Generate.
What Is a bcrypt Generator?
The bcrypt generator hashes a password with bcrypt at a cost from 4 to 31 and the $2b$, $2y$ or $2a$ prefix, checks a password against an existing bcrypt hash, and creates htpasswd lines for Apache and nginx with bcrypt, APR1-MD5 or SHA-1. It counts the password's UTF-8 bytes and warns when bcrypt's 72-byte limit cuts the password off. Hashing runs in a background worker, so a high cost cannot freeze the page, and the tool estimates how long a cost takes on your device before you start.
How to Use the bcrypt Generator
- Pick Generate, Verify or htpasswd.
- Enter the password. For Generate, change the cost or the prefix under Options if needed and check the time estimate. For Verify, paste the hash.
- Press Generate, Verify or Create lines. A high cost runs in the background and can be cancelled.
- Copy the hash, or the .htpasswd file content and the server configuration.
How It Works
bcrypt expands the Blowfish cipher state with the salt and the password, repeated a number of rounds set by the cost. The cost is the base-2 logarithm of the round count, so each step doubles the work (OpenBSD crypt(3)), and crypt(5) allows costs from 4 to 31. The salt is 128 bits. A hash is the prefix, the two-digit cost, and 53 characters of salt and hash, 60 characters in all.
bcrypt uses at most 72 bytes of the password (crypt(5), OpenBSD). PHP truncates longer passwords to 72 bytes, Python bcrypt now raises an error for them, and bcryptjs does not check the length. UTF-8 encodes a character in 1 to 4 bytes, so the tool counts bytes, not characters, cuts at 72 bytes as PHP does, and says so.
$2b$ is the prefix OpenBSD 5.5 introduced, and crypt_blowfish 1.3 treats it exactly like its own $2y$, which marks correctly computed hashes. $2a$ and $2x$ provide bug compatibility with crypt_blowfish 1.0.4 and earlier, which processed characters with the 8th bit set incorrectly (CVE-2011-2483). The tool computes the hash once and writes the prefix you pick. That is safe for UTF-8 passwords, because the $2a$ safety measure only affects passwords containing the byte 0xFF, which never appears in valid UTF-8 (libxcrypt).
An htpasswd file holds one user:hash line per user. Apache recognizes five formats: bcrypt as $2y$ followed by the crypt_blowfish result, an Apache-specific MD5 format ($apr1$) iterated 1,000 times, unsalted SHA-1 ({SHA}), the system crypt(), and plain text on Windows and NetWare only. Its htpasswd program accepts bcrypt costs from 4 to 17 and uses 5 by default. User names are limited to 255 bytes and may not contain a colon.
nginx reads the same file format. It documents APR1, SHA-1 and passwords encrypted with the crypt() function, so bcrypt works only where the operating system's crypt() supports it. crypt(5) lists bcrypt support on OpenBSD, recent FreeBSD and NetBSD, Solaris 10 and newer, and several Linux distributions.
htpasswd Password Formats
| Format | Stored as | Status |
|---|---|---|
| bcrypt | $2y$ + the crypt_blowfish result | Very secure, according to Apache |
| APR1-MD5 | $apr1$ + an Apache-specific MD5 digest iterated 1,000 times | Specific to Apache, and nginx reads it too. The htpasswd default since 2.2.18 |
| SHA-1 | {SHA} + Base64 of an unsalted SHA-1 digest | Insecure |
| crypt() | The system crypt() result; DES crypt uses only the first 8 characters | Insecure; not offered here |
| Plain text | The password itself, on Windows and NetWare only | Insecure; not offered here |
Standards
Scope
What It Checks
- +Generates bcrypt hashes at any cost from 4 to 31, with the $2b$, $2y$ or $2a$ prefix and a new random 16-byte salt each time.
- +Verifies a password against a bcrypt hash with the $2a$, $2b$, $2x$ or $2y$ prefix, and shows the prefix, cost, salt and checksum. It also checks APR1-MD5 and SHA-1 lines from an htpasswd file.
- +Counts the password's UTF-8 bytes and warns when the 72-byte limit cuts it, including a cut inside a character.
- +Names the problem with a malformed hash: a wrong length, a cost out of range, characters outside the bcrypt alphabet, or a WordPress hash.
- +Creates htpasswd lines for up to 50 users with bcrypt, APR1-MD5 or SHA-1, plus Apache and nginx configuration snippets.
- +Runs bcrypt in a background worker with a Cancel button, and estimates the time for a cost on your device first.
What It Does Not Check
- -It does not generate Argon2, scrypt or PBKDF2 hashes.
- -It does not offer crypt() (DES), plain text, or SHA-256 and SHA-512 crypt for htpasswd files.
- -It does not hash passwords that contain a NUL character.
- -It does not keep passwords. Nothing goes to the URL, browser storage or the network.
Defensive Use
OWASP recommends Argon2id for new password storage and, for legacy systems using bcrypt, a work factor of 10 or more with passwords limited to 72 bytes. Apache's htpasswd documentation calls bcrypt very secure and calls the SHA-1 and crypt() formats insecure by today's standards.
Frequently Asked Questions
What is a bcrypt Generator?→
The bcrypt generator hashes a password with bcrypt at a cost from 4 to 31 and the $2b$, $2y$ or $2a$ prefix, checks a password against an existing bcrypt hash, and creates htpasswd lines for Apache and nginx with bcrypt, APR1-MD5 or SHA-1. It counts the password's UTF-8 bytes and warns when bcrypt's 72-byte limit cuts the password off. Hashing runs in a background worker, so a high cost cannot freeze the page, and the tool estimates how long a cost takes on your device before you start.
What is the bcrypt Generator used for?→
Creating a password hash for a configuration file or a test account, checking whether a password matches a stored bcrypt hash, and setting up basic authentication for an Apache or nginx site.
Is my data sent anywhere?→
No. The bcrypt Generator runs in your browser. What you enter stays on this page and is not sent to ImmunitySec or anyone else.
How is the bcrypt Generator used defensively?→
OWASP recommends Argon2id for new password storage and, for legacy systems using bcrypt, a work factor of 10 or more with passwords limited to 72 bytes. Apache's htpasswd documentation calls bcrypt very secure and calls the SHA-1 and crypt() formats insecure by today's standards.
What does the bcrypt cost mean?→
The cost is the base-2 logarithm of the number of rounds, so cost 12 means 4,096 rounds and each step doubles the time (OpenBSD crypt(3)). OWASP asks for a work factor of 10 or more, PHP 8.4 raised its default from 10 to 12, and Apache's htpasswd uses 5 by default.
Why is a password over 72 bytes a problem?→
bcrypt uses at most 72 bytes of the password (crypt(5)). PHP truncates longer passwords, so two passwords that share their first 72 bytes get hashes that verify for either one. OWASP advises enforcing a maximum password length of 72 bytes. UTF-8 encodes a character in 1 to 4 bytes, so the limit can be fewer than 72 characters.
Which prefix should I pick: $2a$, $2b$ or $2y$?→
crypt(5) lists $2b$ as the bcrypt prefix and says $2y$ is equivalent to it. Apache writes $2y$. $2a$ exists for bug compatibility with crypt_blowfish 1.0.4 and earlier. Pick the prefix that the software reading the hash expects.
Why does the same password give a different hash each time?→
Each hash gets a new random salt. crypt(5) explains that a salt perturbs the hash function so that the same passphrase may produce many possible hashes, and bcrypt uses a 128-bit salt (OpenBSD).
Should a new system use bcrypt?→
OWASP recommends Argon2id with at least 19 MiB of memory, 2 iterations and 1 degree of parallelism. It lists bcrypt for legacy systems, with a work factor of 10 or more and a password limit of 72 bytes.