htpasswd Generator
Create Apache and Nginx basic-auth entries with bcrypt, in your browser.
About the htpasswd Generator
An .htpasswd file stores user names with password hashes for HTTP basic authentication in Apache and Nginx. Each line has the form user:hash.
The generator creates the hash in your browser. Use bcrypt: it is slow by design and salted, which makes stolen files hard to crack. APR1-MD5 and SHA-1 are offered only for old systems that cannot read bcrypt.
How to use it
- Enter a user name and a password (or generate one).
- Choose bcrypt and a cost factor (10–12 is a good range).
- Copy the line into your .htpasswd file.
Frequently asked questions
Which htpasswd algorithm should I use?
bcrypt. Apache supports it since 2.4 and Nginx reads it where the system crypt library supports it (most current Linux distributions). APR1-MD5 and SHA-1 are fast and easy to brute-force.
How do I use the file with Nginx?
Save the line in a file such as /etc/nginx/.htpasswd, readable by Nginx but not web-accessible, and add auth_basic "Restricted"; plus auth_basic_user_file /etc/nginx/.htpasswd; to the location block.
Is basic authentication secure?
Only over HTTPS: the browser sends the credentials with every request, merely encoded, not encrypted. Combine it with TLS, strong passwords and, where possible, IP restrictions.