htpasswd Generator
Hash user passwords in your browser, build or edit a whole .htpasswd file, check a password against a line and copy the matching server config.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Pick the format
Choose bcrypt for Apache, or APR1 for Nginx on older systems, and set the bcrypt cost.
- 2Add a user
Type a user name and a password, or tap Generate a strong password, then tap Add user.
- 3Add many at once
Paste user:password lines or plain names into Add many users and tap Hash and add all; copy any generated passwords straight away.
- 4Review the list
Check the users table, remove anyone who should not have access and open an old file if you are updating one.
- 5Copy the config
Set the file path and realm, then copy the Apache, .htaccess or Nginx block.
- 6Upload and test
Download the .htpasswd file, put it on the server outside the web root and test the login over HTTPS.
About this tool
Basic authentication is the quickest way to put a password on a staging site, an admin folder or a test API: the server reads a small text file with one user:hash line per person and asks the browser for a name and password. The file is normally made with the htpasswd command that ships with Apache, which is not installed on most laptops or on Nginx-only servers. This generator makes the same lines in the browser. Choose bcrypt, the slow, salted format Apache recommends, and its cost factor; Apache MD5 with the $apr1$ prefix, which every Apache and Nginx version reads; unsalted SHA-1 with {SHA} for old setups; salted SHA-1 with {SSHA}, which Nginx accepts; or {PLAIN} for a throwaway test. The APR1 code produces exactly the same lines as openssl passwd -apr1 and the bcrypt code is the same tested implementation the site uses for WordPress hashes. Add users one by one with a strength estimate and a strong password generator, or paste a list of user:password lines, or plain user names to get a generated password each, and hash them all in one go. Open an existing .htpasswd file to add, replace or remove users without retyping the others; duplicate names and broken lines are reported.
Checking a password
Paste a whole line or just the hash, type a password, and Check tells you whether it matches. This works for bcrypt, APR1, SHA and SSHA lines and is handy when someone says the password no longer works. Older crypt formats such as DES and the $1$, $5$ and $6$ system hashes are recognised but cannot be checked here.
Server configuration
Set the path where the file will live and the realm text that appears in the login prompt, then copy a ready block for Apache's main configuration, for an .htaccess file, or for an Nginx location. Keep the file outside the public web folder and readable only by the web server user, and only use basic auth over HTTPS, because the browser sends the password with every request.
Which format to choose
For Apache, bcrypt with a cost of 10 to 12 is the best choice. For Nginx, APR1 works everywhere; bcrypt works only where the system crypt library supports $2y$, which includes Alpine and recent Debian and Ubuntu releases with libxcrypt, but not older glibc systems. The note under the form spells this out for the format you pick.
Limits
This tool does not upload anything or log in to your server; you copy the file there yourself. Passwords are never saved: the project keeps only user names and hashes. Basic authentication is not a replacement for real accounts with rate limits and two-factor login, and APR1 and SHA lines can be attacked quickly if the file leaks, so use strong passwords and bcrypt where you can.
Worked example
A staging site needs two users. Alice gets a generated 20-character password, around 130 bits by the estimate, and a bcrypt line with cost 10, which means 1,024 rounds of the key schedule. Bob is added from a list line bob:Correct-Horse-7 with APR1 for an Nginx server; checking the APR1 test line for the password x with salt ab gives $apr1$ab$eIePjsejfBGR8ITtu2z0U1, the same as openssl. The Nginx tab then gives auth_basic "Restricted area" and auth_basic_user_file /etc/apache2/.htpasswd.
Quick facts
- Category: Developer & Data
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: Apache HTTP Server 2.4 documentation: Password formats (bcrypt, APR1 MD5, SHA1) and the Nginx auth_basic module
Frequently asked questions
Which hash format is the safest?
bcrypt. It is salted and deliberately slow, and the cost factor lets you make it slower as computers get faster. APR1 is salted but fast, SHA is neither salted nor slow, and PLAIN stores the password as it is.
Does Nginx support bcrypt lines?
Nginx passes the hash to the operating system's crypt function. Systems using libxcrypt, such as Alpine, recent Debian and Ubuntu, Fedora and Arch, understand $2y$. Older glibc systems do not, and login fails silently; use APR1 there.
What bcrypt cost should I use?
Each step doubles the work. Cost 10 takes a few tens of milliseconds on a server and is a common default; 12 is stronger but slows every request, since basic auth checks the password each time. Avoid going above 12 for basic auth.
Can I edit an existing .htpasswd file?
Yes. Tap Open .htpasswd, then add users to replace their lines or remove them from the table. Users you do not touch keep their existing hashes. Download the file again from the .htpasswd tab.
Are my passwords stored?
No. Passwords are hashed in the page and then cleared from the form. The project saves only user names and hashes in this browser, the same thing the server file contains.
Why does the bcrypt warning mention 72 bytes?
bcrypt only reads the first 72 bytes of a password and ignores the rest. Very long passphrases, or ones with many non-English characters that take several bytes each, may be cut. The form warns when that happens.
