How to use the Htpasswd Generator
- 1
Enter a username and password
Usernames cannot contain spaces or colons.
- 2
Choose the hash
bcrypt for modern servers, APR1 for maximum compatibility.
- 3
Add users
Each press adds a line; re-adding a username replaces its old line.
- 4
Copy the config
Set the server path and prompt text, then copy the Apache or Nginx lines.
Features
bcrypt cost 10
Written with the $2y$ prefix that Apache’s own htpasswd uses.
APR1 with random salt
An 8-character random salt per user, compatible with Apache and Nginx.
Multi-user files
Build a whole .htpasswd file, then download it.
Update a user
Adding an existing username overwrites the old hash.
Server snippets
AuthType, AuthName, AuthUserFile and auth_basic lines filled in for you.
Password field clears
The password box empties after each user is added.
Who uses it — and for what
Staging sites
Hide a work-in-progress site from the public and search engines.
Private folders
Protect downloads, reports or a client preview.
Admin panels
Add a second lock in front of an admin login.
Learning
See how Apache password hashes are built.
How to password-protect a website
- Add one or more users above. Each line of the
.htpasswdfile isusername:hash. - Upload the .htpasswd file to your server, ideally outside the public web folder, and set the path field to its full location.
- Apache: put the generated lines in a
.htaccessfile in the folder you want to protect (requiresAllowOverride AuthConfig). Nginx: add the two lines inside the relevantserverorlocationblock and reload Nginx.
Visitors then see the browser’s login prompt before any page loads — ideal for staging sites, admin areas and client previews.
Which hash to choose
bcrypt ($2y$) is the strongest and works with Apache 2.4+ and Nginx on systems whose crypt library supports it (most modern Linux). APR1-MD5 ($apr1$) is the long-standing Apache default and is understood everywhere, including Nginx. SHA-1 ({SHA}) is unsalted and only for very old setups. Basic authentication sends the password with each request, so always use HTTPS.
Everything is computed by your browser’s built-in Web Crypto API — keys, passwords and secrets are never sent to a server, logged or stored. You can even disconnect from the internet after the page has loaded.
Mistakes that break basic auth
- Using a URL for AuthUserFile. It must be a file-system path such as
/home/user/.htpasswd; a relative path is read from the server root, not from the folder you are protecting. - Leaving .htpasswd in a public folder on Nginx. Apache’s default configuration refuses to serve files starting with
.ht, but Nginx has no such rule unless you add one, so a file in the web root may be downloadable. Keep it outside the public folder. - Expecting a logout button. Browsers remember basic-auth credentials until they are closed, so on shared computers close the whole browser after use.
- Forgetting the list resets. Users are held only in this page’s memory; download the file before refreshing or closing the tab.
Command-line equivalents
If you have shell access, Apache’s own htpasswd utility does the same job: htpasswd -c /home/user/.htpasswd admin creates the file and asks for a password, -B selects bcrypt and -C sets its cost. Leave out -c when adding further users, because it overwrites the existing file. Many hosting control panels offer the same feature as a “directory privacy” or “password protect” option. This generator is useful when you have no shell, are on Windows, or want to prepare the file and config before uploading. Remember that basic auth protects a whole folder with a shared prompt — for per-user accounts and rate-limited logins an application login is still needed, ideally with hashes from the Bcrypt Generator.
Worked examples
APR1 step by step
The password password with the salt abcdefgh gives $apr1$abcdefgh$FBwExRW4dCc8aL.OvjpIE1 — the same result as openssl passwd -apr1 -salt abcdefgh password. The tool picks a fresh random salt for every user, so your own output will differ each time, and that is correct.
Line lengths
A finished line is username:hash. An APR1 hash is 37 characters, a bcrypt hash 60 and a {SHA} hash 33 — for example {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= for password. Because {SHA} has no salt, two users with the same password get identical lines, which is one reason it is only for legacy systems.
What the browser actually sends
After you log in as admin with password s3cret, every request carries Authorization: Basic YWRtaW46czNjcmV0. That value is just Base64 of admin:s3cret and can be decoded by anyone who sees it, which is why basic authentication must only be used over HTTPS.
Pro tips
- Put staging sites behind basic auth rather than relying on robots.txt — a password stops both people and crawlers.
- After uploading, test in a private window: you should get the login prompt, a wrong password should be refused, and the right one should load the page.
Glossary
- Basic authentication
- An HTTP login method where the browser sends username:password in Base64 with each request.
- Realm
- The label in the login prompt (AuthName / auth_basic); browsers group saved credentials by it.
- APR1
- Apache’s variant of the md5crypt algorithm: MD5 repeated 1,000 times with a salt.
Frequently asked questions
Does Nginx support bcrypt in .htpasswd?
Nginx uses the system crypt() function; most current Linux distributions support bcrypt, but APR1 is the safest choice for older systems.
How do I add several users?
Press “Add user” for each one; all lines are collected in the file.
Is the password sent to the server?
No — hashing happens in your browser.
Can I edit a password later?
Add the same username again with the new password; the tool replaces that line. Then upload the updated file.
Why does the bcrypt hash start with $2y$?
That is the prefix Apache’s htpasswd writes for bcrypt; it is the same algorithm as $2b$ and is what Apache expects.
Does the tool save my users?
No. The list lives only in the open page, so download the .htpasswd file before you leave.
Last updated 2026-11-28 · Built by Vinayak Agarwal · Part of Security & Privacy (20 tools)