Free htpasswd generator
Htpasswd generator for Apache and Nginx hashed only in your browser
Pick a login and a password, choose bcrypt, apr1 or SHA1, and get one line ready to paste into .htpasswd for basic auth on Apache or Nginx.
- Free, no sign-up
- Login and password stay on your device
- bcrypt by default
From a login to a pasted line
Every change redraws the line, so what you see is exactly what you copy into the file.
- Step 01
Type the login
The name your visitors enter in the browser prompt. Colons and spaces are refused, because they would break the file.
- Step 02
Own or generated password
Type a password you already have, or let the tool draw one with the length and character types you choose.
- Step 03
Choose the hash
bcrypt is selected for you. apr1 and SHA1 are there for older setups, and SHA1 comes with a plain warning.
- Step 04
Copy the line
One tap copies login:hash. Paste it as a new line in .htpasswd and keep the password in your manager.
What you get with every line
- A finished login:hash line, not just a bare hash
- bcrypt with the $2y$ prefix that Apache reads, at cost 10
- apr1 and SHA1 for servers that need them
- Your own password or a random one of 4 to 128 characters
- Strength shown as bits, or as Weak, Fair or Strong for your own text
- Hashing runs in your browser and never blocks the page
- Copy the line or just the password
- Nothing typed is saved: only length, character types and algorithm are remembered
How an .htpasswd file works
login:hash admin:$2y$10$<22-char salt><31-char hash>
An .htpasswd file is a plain text list of people allowed through basic authentication. Each line holds a login, a colon and a hash of the password. The server never stores the password itself: when a visitor answers the browser prompt, it hashes what they typed and compares the result with the line for that login.
bcrypt is the recommended choice. It is deliberately slow and adds a random salt, so two identical passwords give different lines and guessing at scale costs a lot of time. Apache reads the $2y$ prefix, and Nginx can use it on systems whose crypt library supports bcrypt. The cost value, 10 here, sets how much work one hash takes.
apr1 is the Apache variant of MD5 hashing, repeated a thousand times with a salt. It works almost everywhere, including older servers and Nginx, but it is much faster to attack than bcrypt. SHA1 stores a bare, unsalted digest after the {SHA} marker. The same password always gives the same line, so leaked lines can be matched against tables of common passwords. Use it only when nothing else is accepted.
To fill the fields, enter the login first. Then either keep the generated password, which you can reshape with the length slider and the lowercase, capital, digit and symbol boxes, or switch to your own password and type it. The line updates after each change. If you only need a strong password, you can ignore the hash part.
Save the copied line into a file, one login per line. A common name is .htpasswd, kept outside the public web root so nobody can download it. In Apache, point AuthUserFile at the full path of the file and add AuthType Basic, AuthName and Require valid-user to the directory or .htaccess. In Nginx, set auth_basic to a prompt text and auth_basic_user_file to the same path, then reload the server.
Basic authentication sends the password with every request, so serve the protected area over HTTPS. For another person, add another line; to change a password, replace that person's line with a newly generated one.
Worked example: sizes and strength
These figures come from the same code that builds your line. Hash lengths are the characters after the colon.
| bcrypt hash length | 60 characters |
|---|---|
| apr1 hash length | 37 characters |
| SHA1 hash length | 33 characters |
| 16 random characters, letters and digits (pool of 62) | 95.3 bits |
| 24 random characters, all four types (pool of 85) | 153.8 bits |
The salt is new each time, so the same login and password give a different bcrypt or apr1 line on every run.
What this tool does not do
- It makes one login at a time. For several people, build a line for each and paste them one under another.
- It cannot open or merge an existing .htpasswd file, and it does not check a password against a hash.
- The hash is computed in this browser tab. A fresh salt is used each time, so a line you made earlier cannot be reproduced; keep the one you copied.
- It does not write Apache or Nginx configuration, and the bcrypt cost stays at 10.
Htpasswd questions
Which algorithm should I pick?
bcrypt, unless your server cannot read it. It is slow to attack and salted. Choose apr1 for older Apache or Nginx builds, and SHA1 only as a last resort.
Is it safe to type a password into a web page?
Here the hash is made inside your browser. The login and password are not sent anywhere and not stored, and you can go offline after the page loads.
Where do I put the line?
Add it to a text file, usually named .htpasswd, outside the public web root. Then point AuthUserFile in Apache, or auth_basic_user_file in Nginx, at that path.
Why does the hash change when I press the button again?
bcrypt and apr1 add a random salt. Each line is different but every one of them accepts the same password. SHA1 has no salt, so its line stays the same.
Why is SHA1 marked as weak?
It is fast and unsalted, so attackers can test billions of guesses a second and reuse tables built for common passwords. Modern servers prefer bcrypt.
Which logins are accepted?
Any text without a colon, spaces or control characters. A colon separates the login from the hash, so it cannot be part of the name.
Guides
- QR Code Stopped Working After Printing? Redo 50 in 0.4 sDynamic QR codes deactivated after printing? Rebuild them as static codes from your link list: 50 codes in 0.4 s, free, no sign-up. Try the bulk generator.
- QR Code Generator That Doesn't Expire: 4 Codes TestedStatic QR codes don't expire because the link is stored in the code itself. See how we decoded 4 codes to prove it, then make yours free with Toolper.
- ZIP Code Regex: 5-Digit, ZIP+4 or Both (JavaScript, Tested)Pick the right US ZIP code regex for JavaScript: 5-digit, ZIP+4 or both. See the patterns, the ZIP+4 test result, and try your own codes free in Toolper.
Locking a staging site tonight?
Get the line, paste it into the file and reload the server.
About ToolperLast updated: Privacy