Choosing an algorithm
apr1 is the default of Apache htpasswd -m and is understood by both Nginx and Apache, so it is the safe choice. SHA-1 (the {SHA} prefix, htpasswd -s) is weaker and only worth using when the other end supports nothing else. plain is for debugging only. bcrypt needs an extra module and is not offered here.
htpasswd Generator
Protecting a directory behind a username and password takes one line of user:$apr1$... in a .htpasswd file. But plenty of machines have no httpd-tools installed, and pulling in all of Apache for one password is a poor trade. This page does the arithmetic in your browser.
The apr1 implementation follows Apache and produces byte-identical results to htpasswd -m, so it can be swapped in directly. Passwords never leave the page.
Features
- Three formats — apr1 (the $apr1$ form, the most portable), SHA-1 ({SHA}) and plain.
- Matches the official tool — The apr1 output was verified byte for byte against htpasswd -m and openssl passwd -apr1.
- Salt visible — The current salt is shown and can be regenerated, which explains why one password yields many strings.
- Config included — The two-line Nginx auth_basic snippet and the command to regenerate with the official tool.
How to use
- Enter a username and password. Usernames allow letters, digits and . _ @ - only.
- Pick an algorithm; apr1 is the usual choice.
- Copy the generated line into your .htpasswd file.
FAQ
apr1 or SHA-1?
Prefer apr1. It is the default of Apache htpasswd -m, works with both Nginx and Apache, and is salted with 1000 iterations, so it resists cracking far better than SHA-1. Fall back to {SHA} only when the other end supports nothing else.
Why does the same password produce a different string every time?
Because of the salt. apr1 picks eight random characters per hash and stores them in the result ($apr1$salt$hash), so verification recomputes with that salt and any of those strings will match.
Is the password sent anywhere?
No. Everything runs locally and the page contains no upload path; it works offline. Clearing the field afterwards is still good hygiene.