Password protection for your website –
create a .htpasswd in 2 minutes
This htaccess password generator creates credentials for classic directory protection – using modern bcrypt instead of dusty MD5. The twist: every calculation runs right inside your browser. Your password is never transmitted anywhere; there is no server that could read it. You can even cut your internet connection – the tool keeps working.
- 100 % in your browser – nothing transmitted
- Works offline
- Passwords never leave your device
- Self-test running …
The generator: user, password, ready-made .htpasswd
Enter a username, generate a password (or bring your own), pick an algorithm – the tool handles the rest. Every user you create is added to the file preview on the right, so building a multi-user file takes just a few clicks.
Hashing algorithm
Which hashing algorithm should you pick?
Historically, .htpasswd files know five schemes. Only one of them still deserves a recommendation today – but we explain the others too, because millions of old files are still out there.
| Scheme | Looks like | Rating | Compatibility | Verdict |
|---|---|---|---|---|
| bcrypt | $2y$12$… | secure | Apache 2.4+, nginx on modern Linux | Deliberately slow and salted. The cost factor scales with faster hardware for years to come. Our clear recommendation. |
| MD5 (APR1) | $apr1$… | acceptable | Every Apache, nginx, virtually every host | Apache's home-grown scheme with 1,000 MD5 rounds and a salt. Far too fast for today's GPUs – only viable with a long random password. |
| SHA-1 | {SHA}… | weak | Apache, nginx, some legacy systems | No salt: the same password yields the same hash everywhere – a free lunch for precomputed tables. Use only if there is truly no alternative. |
| crypt(3) / DES | 13 characters | insecure | Ancient systems | Silently truncates passwords after 8 characters – "SuperSecret2026!" quietly becomes "SuperSec". Crackable in minutes. We deliberately don't offer it. |
| Plain text | password | insecure | Windows Apache only | On the usual Linux web space, plain text in .htpasswd simply doesn't work – and whoever grabs the file instantly owns every account. Not offered either. |
One more word on bcrypt and the 72-byte limit: the algorithm processes at most 72 bytes. Everything beyond that is silently ignored by the server – and note that umlauts and emojis take 2 to 4 bytes each in UTF-8. Sounds like a footnote, but it causes the strangest login mysteries in practice. That's why this tool counts bytes live and refuses over-long passwords instead of quietly truncating them.
Bottom line: pick bcrypt if your host runs Apache 2.4 or newer (the standard since 2012, so almost certainly yes). APR1-MD5 remains the fallback for exotic legacy systems – but then please pair it with a random password of 16+ characters from the generator above.
The .htaccess builder: directory protection, ready to paste
The .htpasswd alone protects nothing – only the matching .htaccess activates the password prompt. Click your template together here: whole directory or individual files, all users or just selected ones. Also available as an nginx snippet or a command-line equivalent.
Don't know the absolute server path? Here's how to find it.
Temporarily place a file path.php with the following content in the directory, open it in your browser – the output is your absolute path. Delete the file right afterwards.
<?php echo __DIR__; ?>
Alternatively, your FTP client or your host's control panel often reveals the path (typical patterns are /var/www/vhosts/your-domain.com/httpdocs or /home/customer12345/public_html).
A word of warning: a broken .htaccess makes Apache respond with "500 Internal Server Error" immediately. Keep FTP access at hand so you can delete it if needed – more in the FAQ.
Hash check: how secure is your existing .htpasswd?
Found an old .htpasswd somewhere and can't remember what's inside? Paste its contents – the tool identifies every scheme, rates it, and can optionally check whether a password matches an entry. All of it, needless to say, happens locally in your browser.
Check a password against an entry
bcrypt benchmark: which cost factor fits?
The cost factor determines how long a single password check takes – each step doubles the time. Here's the catch many people miss: with Basic Auth, the server re-checks the credentials on every single request, not just once at login. Set the value too high and every protected page slows down noticeably. This benchmark measures cost 8 through 16 live in your browser.
| Cost | Time per check |
|---|
Rule of thumb: 50–250 ms per check is a sensible corridor (highlighted in green). If you protect a busy area, enable mod_authn_socache on the server – Apache then caches the result and the cost factor may comfortably go higher. Fun fact: Apache's own default is a surprisingly low cost of 5.
Directory protection in 4 steps
-
Create credentials
Set username and password in the generator above, pick bcrypt, add to the file. Need accounts for colleagues? Just add more users – everything ends up in one file.
-
Upload the .htpasswd
Upload the file via FTP/SFTP – ideally above the web root (next to
httpdocsorpublic_html, not inside). That way it's unreachable from the browser to begin with. -
Set up the .htaccess
Create the template with the builder, fill in the absolute path, and place the .htaccess in the directory you want to protect. Already have a .htaccess there? Simply add the lines at the top.
-
Test it
Open the address in a private browser window – the password prompt must appear immediately. Try once with a wrong and once with the right password. Done: your website is password-protected.
FAQ – common questions about htaccess password protection
What exactly is a .htpasswd file?
A plain text file with one line per user, following the pattern username:passwordhash. The Apache web server (and nginx too) compares submitted credentials against this file once a .htaccess activates the protection. The password itself never appears in plain text – only its hash is stored, a kind of cryptographic fingerprint.
Are my passwords transmitted to a server?
No, at no point. This website password generator computes everything in your browser – there simply is no server-side code that could receive input. You can verify it yourself: open the network tab of your dev tools (F12), or just switch off Wi-Fi. The generator keeps working. Close the page and everything is gone; nothing is stored, not even settings. By the way: the site's anonymous visitor counting (see privacy policy) is entirely separate – it works without cookies by default, recognition cookies are only set with your consent, and neither has anything to do with your input in the generator.
What does “self-test passed” in the header mean?
On load, the tool recomputes a set of built-in test vectors – known passwords whose correct bcrypt, MD5 (APR1) and SHA-1 hashes were generated in advance with the server world's reference implementations (including OpenSSL). The green check mark only appears if every result matches bit for bit. At a glance, you can see that the cryptography works correctly in your specific browser and hasn't been corrupted by an exotic browser, an old device or a partially loaded page. If the test fails, the page says so openly – in that case, don't generate hashes; reload the page first.
Which hashing algorithm should I choose?
Short answer: bcrypt. It's salted, deliberately compute-intensive and has been under scrutiny for over 25 years. Apache supports it since version 2.4 (released 2012) – a non-issue with practically every current host. Only fall back to APR1-MD5 if a genuinely old system is involved, and then please with a long random password. The full rating of every scheme is in the table above.
How do I find the absolute server path for AuthUserFile?
The single most common stumbling block. Apache needs the path in the server's file system (say /var/www/vhosts/example.com/.htpasswd), not the web address. Fastest route: the PHP one-liner from the builder – put <?php echo __DIR__; ?> in a file, open it, read the path, delete the file. Many hosting panels also show the path under keywords like "directory protection" or "web space path".
Where do the .htpasswd and the .htaccess go?
The .htaccess goes into exactly the directory you want to protect – it automatically covers all subdirectories as well. The .htpasswd is best stored outside the publicly reachable web folder, one level above httpdocs, htdocs or public_html. If your host doesn't allow that, no drama: by default, Apache blocks direct access to any file starting with .ht anyway.
I get "500 Internal Server Error" after setting it up – now what?
Almost always one of three classics: a typo in the .htaccess, a wrong AuthUserFile path, or a directive your host doesn't permit. First aid: rename the .htaccess via FTP (e.g. to htaccess.txt) – if the site comes back, the file is definitely the culprit. Then double-check the path, regenerate the file with the builder and test step by step. Your host's error log usually names the cause outright.
The password prompt doesn't appear at all – why?
Then the server is most likely ignoring your .htaccess entirely. On your own server/VPS, the vhost must have AllowOverride AuthConfig (or All) – the default is often None. On shared hosting, .htaccess support is almost always active; check instead whether the file is really called .htaccess (with the dot, no extension) and sits in the right directory. Some FTP clients hide dot files by default, by the way.
Does this work with nginx too?
Yes, with two differences: nginx doesn't read .htaccess files – the protection belongs directly in the server configuration (auth_basic and auth_basic_user_file; the ready-made lines are in the builder's nginx tab). And which hash schemes work depends on the system's crypt library. Current Linux distributions accept bcrypt hashes in the $2y$ format without complaint.
How do I add more users later?
Simply create another user here and append the new line to the end of your existing .htpasswd – exactly one line per user, order doesn't matter. Or rebuild the whole file in the generator: entries stay in the preview until you close the page. To remove a user, just delete their line.
How secure is HTTP Basic Auth overall?
The mechanism itself is simple: the browser sends username and password with every request – merely Base64-encoded, which is not encryption. Without HTTPS, anyone listening in could grab the credentials in plain text. Hence the clear rule: use directory protection only together with HTTPS (free at almost every host these days thanks to Let's Encrypt). With that in place, Basic Auth is a perfectly solid, battle-tested shield for staging environments, internal areas and client previews.
I forgot the password – can I get back in?
The password cannot be recovered from the hash – that's the whole point. Fortunately the fix is unspectacular: generate a new password here, replace the affected line in the .htpasswd with the new one, done. No data is lost; only the credentials change.
Why doesn't the generator offer crypt(3) or plain text?
On principle. crypt(3) truncates passwords after 8 characters without telling you – the rest of your nice long password does nothing, and such a hash is cracked in minutes. Plain text, in turn, doesn't even work on Linux servers and would be a total loss if the file ever leaked. A generator that promises security shouldn't offer such traps – not even "for special cases".
Is directory protection enough for sensitive data on its own?
For staging sites, admin areas and downloads for a limited circle: yes – combined with HTTPS and strong passwords, this has been established practice for decades. For highly sensitive data (medical records, financial data and the like), Basic Auth should be just one of several layers, e.g. on top of an application login. And one point that's easily forgotten: the protection only applies via the web server. Anyone with FTP access to the directory can still read the files.