Notes about the password encryption formats generated and understood by Apache.
There are five formats that Apache recognizes for basic-authentication passwords. Note that not all formats work on every platform:
crypt(3)
function
with a randomly-generated 32-bit salt (only 12 bits used) and the first 8
characters of the password. Insecure.OpenSSL knows the Apache-specific MD5 algorithm.
The salt for a CRYPT password is the first two characters (converted to
a binary value). To validate myPassword
against
rqXexS6ZhobKA
Note that using myPasswo
instead of
myPassword
will produce the same result because only the
first 8 characters of CRYPT passwords are considered.
The salt for an MD5 password is between $apr1$
and the
following $
(as a Base64-encoded binary value - max 8 chars).
To validate myPassword
against
$apr1$r31.....$HqJZimcKQFAMYayBlzkrA/
The SHA1 variant is probably the most useful format for DBD authentication. Since the SHA1 and Base64 functions are commonly available, other software can populate a database with encrypted passwords that are usable by Apache basic authentication.
To create Apache SHA1-variant basic-authentication passwords in various languages:
Apache recognizes one format for
digest-authentication passwords - the MD5 hash of the string
user:realm:password
as a 32-character string of hexadecimal
digits. realm
is the Authorization Realm argument to the
Since the MD5 function is commonly available, other software can populate a database with encrypted passwords that are usable by Apache digest authentication.
To create Apache digest-authentication passwords in various languages: