Use this htpasswd file generator to turn a username and password into one line for HTTP Basic Auth on Apache. Any online htpasswd generator does the same job: it hashes your secret with bcrypt or APR1 so the server never keeps it as readable text. Paste the result into your basic authentication setup, and you can password protect a staging folder, an admin area or a private download in minutes.
What an Htpasswd Entry Contains
An htpasswd entry is one line of text shaped like username:hash. The username stays readable, while the password hash is a one-way fingerprint of your secret, so nobody can read the original password back from it. A random salt is mixed in, which means the same password produces a different result every time you generate it. Because the output is one-way and deterministic, the free sha512 hash generator shows how trailing newlines and Unicode input change a fingerprint.
The text file holds one user per line, and Apache compares the credentials a visitor types against those hashes. A single htpasswd line therefore carries everything the server needs to verify a login, and nothing an attacker can reverse into a password.
HTTP authentication runs before any page loads, so a wrong guess never reaches your application. The readable half of each line also shows up in server logs, so pick a username your team will recognise and avoid an email address.
Using the Htpasswd File Generator
The htpasswd file generator on this page works in three moves: enter the credentials, pick a hash type, and copy the line. Whether you need to create htpasswd data for one editor or for ten, the steps stay the same, and generating again simply adds another user. OWASP lists memory-hard functions for authentication, and the free scrypt hash generator lets you see how a larger N raises memory use against a GPU.
Enter a Username and Password
Type a username of up to 255 bytes with no colon or spaces, then type a password, or click the random password button for a cryptographically secure value. The built-in password generator draws from your browser's secure random source, and a long passphrase beats a short complicated string.
Copy the Entry or Download the File
Select copy entry to paste the line into an existing .htpasswd file while keeping other users' lines intact, or download file to save a fresh copy. Because these htpasswd passwords are hashed, it is safe to move between machines, but never leave it in a public folder.
Password Hash Formats for Basic Auth
Every format ends up in the same one-line shape, and its prefix tells the server how to verify it. Choose the algorithm by what your server supports, because a mismatched hash format fails every request. Compatibility matters more than novelty here, and this table compares the options.
| Format | Prefix | Random salt | Best for |
|---|---|---|---|
| Bcrypt | $2y$ | Yes | Apache 2.4 and newer |
| Apache MD5 | $apr1$ | Yes | Older installations |
| SHA-1 | {SHA} | No | Legacy software only |
| Crypt | none | Weakly | Old Unix systems |
Bcrypt Cost on Apache 2.4
It is the right default for modern servers. Its bcrypt cost setting defaults to 10, and each step up doubles the work needed to check one guess, so a stolen copy is slower to crack. The trade-off is that every visitor request is verified too, so very high values add load. It also ignores bytes past 72, which is why long passphrases need care.
APR1 and Apache MD5
The APR1 format is an iterated, salted variant of MD5 made for Apache, not a plain MD5 hash. It is the most widely accepted choice, so reach for this legacy format only when software reading it cannot handle bcrypt.
SHA-1, Crypt and Plain Text
This format writes {SHA} followed by an unsalted digest, so two users with the same password share one result, which invites dictionary attacks. Crypt keeps only the first eight characters of the password, and plain text stores the secret as typed, a setup only Windows and Netware accept. Hashing is not encryption: an encrypted value can be decrypted, a hash cannot, yet all three of these are last resorts.
Locking a Preview Site with One Htpasswd Line
I'm handing a client a redesign preview before launch, and only their editor should see it. The decision: which format, and how much work per sign-in? I enter the username stagingeditor and the 19-byte password kestrel-Plover-4829, then choose bcrypt at the default cost of 10.
The generator returns stagingeditor:$2y$10$GeQOGaWqvlx6ikTWBXvLdOa.ef.JMHw5pnwTrHmzBCB1DeBrOVRMe. The $2y$ prefix is the one the server's own documentation lists for it, and the documentation recommends it for new files. I paste the line in and test it in a private window: the prompt appears, and the right sign-in loads the page. As a cross-check, running the same password through the openssl passwd command with its MD5 option twice returns two different strings, which confirms a random salt is involved rather than a fixed digest, and that two users sharing a password would not share a stored value.
Then a sensitivity rerun, changing only the cost. Cost 12 produced $2y$12$… instead, and timing it on my machine gave this:
| Cost setting | Time per run | Work vs cost 10 |
|---|---|---|
| 10 | 0.06 s | 1× |
| 12 | 0.16 s | 4× |
What stands out is that the server pays this price on every protected request, so for a preview with two users I keep 10; 12 earns its place only where a leaked list is the bigger worry. The edge case is the 72-byte limit: a 67-character passphrase with accented letters measured 75 bytes, so the last three would be silently ignored, and anyone typing only the first 72 bytes would still get in. When I cannot guarantee the length, I shorten the phrase and test the sign-in again rather than trust the entry.
Configuring Apache to Read the Password File
Save the line in a file named .htpasswd and tell the web server where it lives through an .htaccess block. Apache needs permission to read it, and the directory must allow authentication overrides. Without that configuration, nothing ever asks for credentials.
AuthType Basic
AuthName "Restricted area"
AuthUserFile /home/deploy/secure/.htpasswd
Require valid-userPlace the .htaccess file in the folder you want to restrict. Its rules cover every subfolder beneath it, so one block can limit access to an entire admin area, and each protected folder can reuse one shared list of users.
AuthUserFile and Require Valid-User
Point the file directive at the absolute path, since a relative path is resolved from the server root and fails silently; your hosting panel usually shows the full path. The AuthName text appears in the prompt as the realm, and a wrong path returns a 401 or a 500 error instead of a prompt.
Nginx and Web Root Placement
Keep it outside the public directory, never inside the document root, or anyone could download your list. Nginx ignores .htaccess and uses auth_basic_user_file with the same line format, and mod_rewrite rules do not change that. Serve the protected area over HTTPS, which keeps the connection encrypted, because basic authentication sends credentials with every request.
Why This Htpasswd Generator Runs in Your Browser
Hashing happens in your browser, so the password is never sent to a server and never stored. Because the work is local, you can generate an entry for a private preview without exposing the secret to anyone, including us. A good .htpasswd generator keeps privacy intact by working locally, and you can confirm that in the network tab of your developer tools. Treat the finished line as sensitive anyway: it keeps unauthorized visitors off a staging site only while it stays private.
Tips for Strong Passwords from a Password Generator
Length beats cleverness: for each line you add, choose at least 16 random characters, or four unrelated words, and give every person their own account so you can delete one line without touching the rest. Never reuse an account password for the protected website area, because if the list leaks, a weak secret still falls quickly. For security, share the finished line only through a private channel, test the prompt in a private window after every change, and keep a backup of your list.
Frequently Asked Questions
- Which hash type should I choose?
- bcrypt (this tool's default) has been supported since Apache 2.4.4 and is the modern recommendation -- it's slower to brute-force and has a tunable cost factor. Use APR1-MD5 only if you need compatibility with an older Apache installation, or with other tools (like this site's own htpasswd verification workflow) that specifically expect that legacy format.
- How do I use the generated line?
- Paste it as one line into your .htpasswd file (one user per line), then reference that file in your Apache config with AuthUserFile pointing at its path, alongside AuthType Basic and Require valid-user directives -- Apache's standard Basic Authentication setup.
- How was APR1-MD5 verified to be correct?
- This tool's hand-rolled APR1-MD5 implementation (the same algorithm as the classic Unix "MD5-crypt", just with Apache's $apr1$ magic string instead of $1$) was tested against the real, locally installed htpasswd command-line tool for two independent password/salt combinations, and matched byte-for-byte both times -- not just self-consistency, an actual external reference tool's real output.
- Can multiple users share the same .htpasswd file?
- Yes -- that's the standard use case. Generate one line per user (each with their own random salt, even for the same password) and append each to the same file, one entry per line.
- Is my password sent anywhere?
- No. The hash is computed entirely in your browser -- nothing is transmitted to a server or stored.