htpasswd Generator

Create Apache/Nginx .htpasswd entries with APR1 (MD5) or SHA-1 hashing.

Free htpasswd generator. Create Apache and Nginx .htpasswd username:hash entries using the APR1 (Apache MD5) crypt format or the SHA-1 base64 scheme. Privacy-first — your password is hashed entirely in your browser and never sent anywhere. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Which algorithm does this use?

APR1 implements Apache's $apr1$ MD5 crypt format exactly — a 1000-round MD5 derivation with an 8-character random salt and Apache's custom base64 ordering. The SHA-1 option produces {SHA} followed by base64 of SHA1(password), the htpasswd -s format.

htpasswd generator

Create .htpasswd entries for Apache and Nginx HTTP Basic Auth. Choose the APR1 (Apache MD5) crypt format used by htpasswd -m, or the SHA-1 {SHA} base64 scheme used by htpasswd -s, and copy the username:hash line straight into your password file. Your password is hashed entirely in your browser and never leaves your device.

What is a .htpasswd file?

A .htpasswd file is a plain text file where each line holds one user’s credentials in username:hashed_password format. Apache and Nginx read it at request time to verify HTTP Basic Auth credentials. You point your server at the file with a directive (AuthUserFile in Apache, auth_basic_user_file in Nginx) and protect a location with Require valid-user (Apache) or auth_basic "Realm" (Nginx).

The file is append-only: to add a user, append a new line. To remove a user, delete the line. To change a password, replace the hash on the existing line.

Supported hash schemes

The default scheme used by htpasswd -m. It produces a line starting with $apr1$:

admin:$apr1$Xy3kP9aZ$h0Q1mB2p3...

APR1 uses a random 8-character salt and runs 1000 iterations of a custom MD5-based key derivation. The salt and iteration count mean two things: first, rainbow-table precomputed attacks are useless because every hash is salted differently; second, the same password produces a different hash each time you generate, which is correct and expected. Apache verifies by re-running the derivation with the embedded salt.

SHA-1 ({SHA} base64) — legacy

The htpasswd -s format. It produces {SHA} followed by base64-encoded SHA1(password):

admin:{SHA}5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8

SHA-1 is unsalted so it is deterministic (same password always produces the same hash) and faster to crack with a GPU. Use it only when a specific tool requires the {SHA} format.

How it works

For APR1 the tool runs the published Apache algorithm in pure JavaScript: a cryptographically random 8-character salt is generated, then 1000 rounds of MD5 repeatedly fold the password, salt, password length and intermediate digests together. The result is encoded with Apache’s custom base64 alphabet (. and / instead of + and /) to produce the final hash. For SHA-1 the Web Crypto API is used: subtle.digest('SHA-1', passwordBytes) and the result is base64-encoded.

Deploying the generated entry

Apache

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /var/www/.htpasswd
Require valid-user

Place the .htpasswd file outside your document root if possible, so it cannot be served as a static file.

Nginx

location /admin {
    auth_basic "Restricted Area";
    auth_basic_user_file /etc/nginx/.htpasswd;
}

Scheme comparison

SchemeFormatSaltedDeterministichtpasswd flag
APR1$apr1$salt$hashYesNo-m
SHA-1{SHA}base64NoYes-s

Always serve HTTP Basic Auth over HTTPS. The protocol base64-encodes credentials, which is trivially reversible; TLS is the only thing that keeps them private in transit.