Generate password entries for Apache .htpasswd files. Enter a username and password to create SHA-1 hashed authentication entries for securing web directories.
1. Copy the generated line above.
2. Create or edit a file named .htpasswd on your server.
3. Paste the line into the file (one entry per line).
4. Create a .htaccess file in the directory to protect:
AuthType Basic\nAuthName "Restricted Area"\nAuthUserFile /full/path/to/.htpasswd\nRequire valid-user
A .htpasswd file is used by the Apache web server to store usernames and encrypted passwords for HTTP Basic Authentication. When a directory is protected with .htpasswd, visitors must enter a valid username and password to access it. The file contains one entry per line in the format username:encrypted_password.
This tool generates .htpasswd entries using the SHA-1 hashing algorithm, which is supported by Apache's {SHA} scheme. The password is hashed using SHA-1 and encoded in Base64. While bcrypt ({$2y$}) is stronger, it cannot be computed client-side in the browser. For production servers handling sensitive data, consider using the htpasswd command-line tool with bcrypt support.
To protect a directory, you need two files: .htpasswd (containing the credentials) and .htaccess (containing the authentication directives). Place the .htpasswd file outside your web root for security so it cannot be downloaded by visitors. The .htaccess file goes in the directory you want to protect and references the full server path to the .htpasswd file.