Skip to main content

HTPASSWD Basic Auth Generator

Generate Nginx and Apache .htpasswd entries with bcrypt or MD5 hashing

HTPASSWD Basic Auth Generator

Maximum 255 characters; colons and line breaks are not allowed.

Processed locally in this browser and not stored. Maximum 4096 characters.

Hashes are computed locally with the real bcrypt, Apache APR1-MD5, and {SHA} algorithms, so the generated entry works directly with Apache htpasswd files and nginx auth_basic_user_file. Nothing is sent to a server.

Generated `.htpasswd` File Entry

Was this HTPASSWD Basic Auth Generator helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with HTPASSWD Basic Auth Generator

  • Generate htpasswd line
  • Create nginx basic auth password

How this security utility works

Generate valid .htpasswd entries for HTTP Basic Auth using real bcrypt, Apache APR1-MD5, or SHA-1 hashing.

Example input

Username: admin | Password: EasyUtils QA vector | Algorithm: bcrypt (cost 10) | Fixed test salt: $2b$10$abcdefghijklmnopqrstuu

Example output

admin:$2y$10$abcdefghijklmnopqrstuuM.6wvu0P2jO7NwjXSfNqSSccGJXNO/u

Practical workflow

  1. Enter the username and password for the protected area.
  2. Choose the algorithm: bcrypt (htpasswd -B, Apache 2.4+), APR1-MD5 (htpasswd -m, the most widely compatible), or SHA-1 (legacy).
  3. Copy the generated line into your .htpasswd file and reference it from Apache or nginx configuration.

Common use cases

  • Protect a staging site with Basic Auth without installing the htpasswd utility.
  • Add a user to an existing .htpasswd file from any machine.
  • Generate nginx auth_basic_user_file entries (APR1 works with stock nginx).

Important notes and limitations

  • Bcrypt generation uses the browser's asynchronous bcrypt implementation and emits Apache's $2y$ identifier; a fixed test salt makes the documented example reproducible.
  • APR1-MD5 is the most widely compatible choice for stock nginx; bcrypt requires Apache 2.4+ or bcrypt-capable crypt support.
  • Bcrypt uses only the first 72 UTF-8 bytes. Longer values are allowed but trigger a warning because additional bytes do not affect the generated hash.
  • Usernames are limited to 255 characters and must not contain colons or line breaks. Passwords are limited to 4,096 characters to bound browser work.
  • Everything runs locally — passwords are never transmitted or stored.
  • SHA-1 entries are deterministic and unsalted, so the New Salt action is unavailable for that legacy algorithm.

Apache & Nginx htpasswd management commands

Generate Bcrypt basic auth record (Recommended)

htpasswd -nbBC 10 devops 'SuperSecretPassword'

Generates a standard htpasswd line using $2y$ Bcrypt with a cost factor of 10, compatible with Apache 2.4 and modern Nginx.

OpenSSL SHA-512 crypt password generation

openssl passwd -6 -salt $(openssl rand -hex 8) 'SuperSecretPassword'

Creates an OS-level $6$ salted SHA-512 crypt hash used by Linux PAM and supported by modern web server auth_basic modules.

Create and secure htpasswd file on web server

touch /etc/nginx/.htpasswd && chmod 640 /etc/nginx/.htpasswd && chown root:www-data /etc/nginx/.htpasswd

Sets restrictive read permissions so only the web server worker process can access the password file.

HTTP Basic Authentication Hash Algorithms Comparison

Format / IdentifierAlgorithmSecurity LevelNginx SupportApache Support
$2y$ / $2b$ (Bcrypt)Eksblowfish key scheduleRecommended (Cost 10-14, memory & CPU hard)Native (via libcrypt / ngx_http_auth_basic)Native (Apache 2.4+)
$6$ (SHA-512 crypt)SHA-512 with salt & roundsStrong (5000+ rounds standard)Supported if host OS libcrypt supports glibc cryptSupported via apr_password_validate
$apr1$ (Apache MD5)Iterated MD5 with saltDeprecated (Fast on GPU, collision prone)Native fallback across all buildsNative default in legacy Apache
{SHA} (Plain SHA-1)Unsalted base64 SHA-1Insecure (Vulnerable to rainbow tables)Supported for legacy migration onlySupported for legacy migration only

HTTP basic auth & htpasswd errors

401 Unauthorized / credentials rejected by Nginx

Cause: Nginx cannot read the .htpasswd file due to filesystem permissions or SELinux context (e.g. file owned by root:root with 600 permissions while Nginx runs as www-data).

Solution: Run 'chmod 640 /path/to/.htpasswd' and 'chown root:www-data /path/to/.htpasswd'. Ensure auth_basic_user_file points to an absolute path.

nginx: [emerg] invalid password format in .htpasswd

Cause: Special characters like colons (:) inside the username, or trailing Windows CRLF newlines in the password file.

Solution: Ensure usernames contain only alphanumeric characters and underscores. Run 'dos2unix .htpasswd' to strip trailing Windows line endings.

High server CPU usage / Nginx worker timeout during authentication

Cause: Bcrypt cost factor set too high (e.g., cost 16+ requires seconds of CPU time per single HTTP authentication request).

Solution: Use cost factor 10 or 12 for web traffic. Each increment of cost factor doubles CPU verification time.

Continue your workflow

  • Bcrypt Generator — Inspect bcrypt cost factors, benchmark execution times, and verify hash strings.
  • Hash Generator — Generate SHA-256 and SHA-512 hashes for system configuration and user records.
  • Password Generator — Create strong random administrative passwords for web server basic auth.
  • HTTP Headers Inspector — Verify WWW-Authenticate and Authorization headers sent by your web server.

Frequently asked questions

How do I create a .htpasswd file without the htpasswd command?

Enter a username and password here, pick an algorithm, and copy the generated user:hash line into a file named .htpasswd. Point Apache's AuthUserFile or nginx's auth_basic_user_file at that file.

Which algorithm should I choose for nginx?

APR1-MD5 is supported by stock nginx everywhere. Bcrypt is stronger and works with Apache 2.4+ and systems whose crypt() supports it; SHA-1 exists only for legacy compatibility.

Are the generated hashes real?

Yes. Bcrypt output uses Apache's $2y$ format and was checked with htpasswd -vb; APR1 follows Apache's apr_md5_encode test vector, and SHA-1 uses htpasswd's {SHA} format.