Htpasswd Generator

Create .htpasswd lines with bcrypt, Apache MD5 or SHA-1, or check a password against one.

About Htpasswd Generator

An htpasswd generator that writes .htpasswd lines with bcrypt, Apache MD5 or SHA-1 for one or many users, and checks a password against a line.

How to use

  1. Choose a format. bcrypt is the default; for bcrypt, set the cost factor (4 to 16, default 10).
  2. Type a user name and password. Add user adds a row; pasting user:password lines into a user name field adds one row per line.
  3. The file updates as you type. Copy it or download it as .htpasswd; New salts hashes every line again with fresh salts.
  4. To check a line, switch to Verify, paste user:hash (or the hash alone) and type the password.

What it does

  • bcrypt lines start with $2y$, the prefix Apache's htpasswd -B writes. Apache's own default cost is 5; this page uses 10. bcrypt reads only the first 72 bytes of a password, and the page warns when one is longer.
  • Apache MD5 lines start with $apr1$, then an 8-character random salt and 1,000 rounds of MD5. The implementation is checked against lines written by Apache's htpasswd.
  • SHA-1 lines are {SHA} followed by the Base64 of an unsalted SHA-1 digest.
  • Apache MD5 and SHA-1 are weak: both are fast to guess, and SHA-1 has no salt, so two users with the same password get the same line. Use bcrypt wherever the server reads it.
Format Apache Nginx
bcrypt Yes (2.4) Only where the system crypt() supports bcrypt
Apache MD5 Yes, htpasswd default Yes
SHA-1 Yes Yes
  • Verify reads bcrypt ($2a$, $2b$, $2y$), $apr1$ and {SHA}. It does not read DES crypt, $1$, $5$, $6$, {SSHA} or plain-text lines.
  • It does not edit a file on a server. To add a user to an existing file, append the new line to it.

Example

user      alice
password  password
→ alice:$apr1$5KOdoUom$GMZXe2NMYXrFgii4knQjO0    (Apache MD5, salt 5KOdoUom)
→ alice:{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=          (SHA-1)

Privacy

Passwords are hashed in JavaScript on this page. Nothing is uploaded and nothing is stored.

Frequently asked questions

How do I create an .htpasswd file without the htpasswd command?
Enter each user name and password here, pick bcrypt, and download the result as .htpasswd. Each line is user:hash, so the file is the same as one written by htpasswd -B.
Which password format does Nginx accept in .htpasswd?
Nginx has its own code for Apache MD5 ($apr1$) and {SHA} lines, so those always work. Other hashes, bcrypt included, go to the system crypt() function, so they work only where that function supports them.
Is htpasswd MD5 secure?
Not by current standards. Apache MD5 is 1,000 rounds of MD5, which a GPU can guess at high speed. Use bcrypt where the server supports it, and keep the file out of the web root.
How do I add another user to an existing .htpasswd file?
Generate a line for the new user and append it to the file, one user per line. If the user already exists, replace that line instead of adding a second one.