Use this free htpasswd generator to create entries for HTTP basic authentication. Enter a username and password, pick a hash, and add the entry to a file that you download as .htpasswd. Apache and Nginx read this file to check logins on protected folders. The hashing runs in your browser, so passwords are not sent anywhere.
An entry is only as strong as its password. Use a long, unique password, because a hash does not protect a weak one for long.
How to use the htpasswd generator
- Enter: a username (no colons or line breaks) and a password.
- Choose: bcrypt is the default. Pick a cost between 8 and 14, where higher is slower.
- Add: generate the entry, then add it. Repeat for each user.
- Download: save the list as
.htpasswd, or copy it as text.
What an entry looks like
Each line is username:hash. A bcrypt hash such as $2y$10$... has three parts: $2y$ names the bcrypt variant, 10 is the cost, and the rest holds the salt and the hash. The salt is random, so the same password gives a different hash each time.
Hash types
- bcrypt ($2y$): salted and slow. The right choice for new files.
- {SHA} (legacy): a plain SHA-1 of the password with no salt. It is fast to guess against, so use it only for an older server that accepts nothing else.
Bcrypt uses only the first 72 bytes of a password. The tool warns when a password is longer, and the rest is ignored by bcrypt.
Common htpasswd mistakes
- Putting the file in the web root. A browser that can request the file can copy every hash in it.
- Using a colon in the username. The colon separates the fields, so it breaks the line.
- Choosing {SHA} for new files. It is unsalted and fast. Use bcrypt unless a server forces otherwise.
- Assuming basic auth is secure over plain HTTP. Credentials travel in each request, so serve the site over HTTPS.
Frequently asked questions
Which hash should I choose?
Use bcrypt. It is salted and slow, which makes guessing harder. Choose {SHA} only when an older server accepts nothing else.
Are my passwords sent or stored?
No. Hashes are computed in your browser and nothing is sent to a server. Clear the page when you are finished.
Where should the .htpasswd file go?
Outside the public web root, readable only by the web server. Check your server's documentation for the exact path and permissions.
Does every server accept bcrypt entries?
Most current Apache and Nginx setups accept $2y$ entries, but support depends on the build and the crypt library. Test a login after you deploy the file.