Ready to generate
Fill in username & password, then click Generate// create secure password hashes for apache basic auth
Generate secure htpasswd hashes for Apache basic authentication. Supports MD5, SHA1, bcrypt and plain text formats. Free, browser-based, no sign-up required.
Ready to generate
Fill in username & password, then click GenerateType the username and password you want to protect your Apache resource with.
Select APR1-MD5 for broad compatibility, bcrypt for strongest security, or SHA1 for portability.
Paste the generated line into your .htpasswd file on the server and configure .htaccess.
The htpasswd Generator creates password hash entries compatible with Apache's
Basic Authentication system. Apache reads a .htpasswd file to verify credentials
before granting access to protected directories. This tool generates those hashed entries
without needing shell access or the htpasswd command.
An .htpasswd file is a flat-file database used by Apache HTTP Server to store usernames and hashed passwords for HTTP Basic Authentication. Each line contains one entry in the format username:hashedpassword.
Use APR1-MD5 for the best compatibility across Apache 2.x versions. Use bcrypt if you're on Apache 2.4+ and want stronger security — bcrypt is computationally expensive which makes brute-force attacks much harder. Avoid plain text in production.
Yes — hashing is performed server-side in PHP, which is necessary for generating proper APR1-MD5 and bcrypt hashes. The password is transmitted over HTTPS and never stored or logged.
SSH into your server and open (or create) the file at a path like /etc/apache2/.htpasswd. Paste the generated line. Then in your .htaccess, add: AuthType Basic, AuthName "Protected", AuthUserFile /path/.htpasswd, Require valid-user.
Yes. Simply generate a hash for each user and append each line to the same .htpasswd file. Each user gets their own line. To update a password, replace the existing line for that username.
SHA1 ({SHA} prefix) is widely supported by Apache and also by Nginx when using auth_basic with the ngx_http_auth_basic_module. However SHA1 is considered weak by modern cryptographic standards — prefer APR1-MD5 or bcrypt where possible.
An htpasswd generator is a tool that creates password hash entries in the format
expected by Apache HTTP Server's Basic Authentication system. When you want to restrict access to
a directory or web resource on an Apache server, the standard approach is to use an .htpasswd
file — a simple text file where each line stores a username paired with a hashed version of their password.
Normally, you'd generate these entries using the htpasswd command-line utility that ships
with Apache. However, that requires shell access to your server. This online generator replicates
the same hashing algorithms in PHP, letting you create valid .htpasswd entries directly
in your browser — no terminal, no Apache installation needed.
Apache supports several password hash formats, each with different security characteristics and compatibility considerations:
$apr1$...) — Apache's own variant of MD5-crypt. It uses
a random 8-character salt and applies 1,000 rounds of MD5 transformations. While MD5 is considered
weak for general cryptographic purposes, APR1-MD5 is a stretched variant specifically designed for
password storage. It's the default format for Apache 2.x on most platforms and offers the widest
compatibility.
{SHA}...) — Stores a Base64-encoded SHA1 hash of the password.
It's simpler and portable but provides weaker security since SHA1 is fast to compute, making brute-force
attacks more feasible. Suitable only for low-security scenarios where compatibility is a priority.
$2y$...) — The most secure option, available in Apache 2.4+.
bcrypt uses a configurable cost factor (this tool uses 10) to deliberately slow down hashing, making
brute-force attacks computationally expensive even with modern hardware. Strongly recommended for
any production environment running Apache 2.4 or newer.
Apache's Basic Authentication mechanism is straightforward. When a browser requests a protected resource,
Apache returns a 401 Unauthorized response with a WWW-Authenticate header.
The browser then prompts the user for credentials and re-sends the request with a Base64-encoded
Authorization header. Apache decodes this, extracts the username and password, finds the
matching username in the .htpasswd file, hashes the submitted password with the stored
salt, and compares against the stored hash.
Because the process happens at the Apache level — before any PHP, Node, or application code runs — it's an efficient and reliable way to protect resources like staging environments, admin panels, or internal documentation.
Once you've generated your htpasswd entries, here's the complete setup process:
/etc/apache2/.htpasswd or
/home/user/.htpasswd. Paste the generated line(s) into this file.
.htaccess file with the following directives:
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /absolute/path/to/.htpasswd
Require valid-user
httpd.conf or a virtual host file), ensure the directory has
AllowOverride AuthConfig or AllowOverride All set.
sudo systemctl reload apache2 (or
service httpd reload on older systems) to apply the changes.
While HTTP Basic Auth is convenient, there are important security considerations to keep in mind:
.htpasswd file is
accessible via HTTP, anyone can download it and attempt to crack the hashes offline.mod_evasive or fail2ban
to block repeated failed authentication attempts.
While this tool is designed for Apache, the SHA1 and plain text formats
are also compatible with Nginx's ngx_http_auth_basic_module. Nginx reads the same
.htpasswd file format and supports SHA1 and crypt-based hashes. APR1-MD5 and bcrypt
support in Nginx may require additional modules or compilation flags depending on your distribution.
For Nginx, the configuration equivalent looks like:
location /protected/ {
auth_basic "Restricted Area";
auth_basic_user_file /path/to/.htpasswd;
}
The command-line htpasswd utility is only available on systems where Apache is installed.
Developers working on Windows, designers setting up staging servers, or anyone without direct server
access often need to generate these entries without a full Apache environment. This online tool fills
that gap — it runs the same hashing algorithms server-side and delivers instantly usable output that
you can paste directly into your server's .htpasswd file.