.htpasswd Generator — Apache & Nginx Basic Auth
Create a username:hash line for HTTP Basic Auth in your browser. Choose bcrypt, APR1-MD5, or SHA-1, get a copy-ready .htaccess snippet, and verify a password against an existing hash. Your password is hashed locally and never uploaded.
How it works
HTTP Basic Authentication (defined in RFC 7617) protects a directory by asking the browser for a username and password. Apache and Nginx check those credentials against a flat file — conventionally named .htpasswd — where every line is username:hash. The server never stores the plaintext password: it hashes whatever the user types and compares the result to the stored hash. This tool builds those lines, using the exact formats Apache's htpasswd program writes.
Three hashing schemes are supported, matching the htpasswd CLI flags:
- bcrypt (
htpasswd -B) — generates a 16-byte random salt and runs the Blowfish-based bcrypt key-derivation function for 2cost rounds, emitting$2y$<cost>$<22-char salt><31-char hash>. The cost factor (4–15) is a deliberate slowdown: each step up doubles the work for an attacker. This is the recommended choice. The bcrypt algorithm caps the password at 72 bytes — anything longer is silently ignored, exactly as Apache does. - APR1-MD5 (
htpasswd -m) — Apache's portable default. It takes a salt of up to 8 characters and runs the Apache Portable Runtime's 1,000-round MD5 mixing (apr_md5_encode), then encodes the digest with Apache's custom base64 ordering to produce$apr1$<salt>$<22-char digest>. Salted, but fast to compute, so weaker than bcrypt against modern cracking hardware. - SHA-1 (
htpasswd -s) — computesSHA1(password), base64-encodes the 20-byte digest, and prefixes{SHA}. It is unsalted by design, which means identical passwords always produce identical hashes — flagged here as insecure and offered only for compatibility with legacy files.
Every salt is drawn from the browser's cryptographic random source (crypto.getRandomValues), not Math.random. Because bcrypt and APR1-MD5 re-salt on each run, the hash text changes every time — that is expected and is why salted schemes can only be checked by re-running the algorithm, which is exactly what the Verify tab and your web server do. The APR1-MD5 implementation here is reconciled byte-for-byte against openssl passwd -apr1 and the published Apache source, and the SHA-1 output matches the canonical digest of the input.
Worked examples
Frequently asked questions
Sources & references
- Apache — htpasswd program (algorithms, -B/-m/-s/-C flags, file format)
- Apache — mod_authn_file (how AuthUserFile / .htpasswd is consumed)
- Apache Portable Runtime — apr_md5.c ($apr1$ 1000-round scheme)
- Nginx — ngx_http_auth_basic_module (supported hash formats)
- OpenBSD — A Future-Adaptable Password Scheme (bcrypt)
- RFC 7617 — The 'Basic' HTTP Authentication Scheme
The hash formats and the APR1-MD5 algorithm were last cross-checked against the Apache source and openssl passwd -apr1 on 2026-06-24.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.