Authen-Passphrase
view release on metacpan or search on metacpan
lib/Authen/Passphrase/MD5Crypt.pm view on Meta::CPAN
passphrase schemes supported by the modern crypt(), see the
L<from_crypt|Authen::Passphrase/from_crypt> constructor and the
L<as_crypt|Authen::Passphrase/as_crypt> method in L<Authen::Passphrase>.
The MD5-based crypt() scheme uses the whole passphrase, a salt which
can in principle be an arbitrary byte string, and the MD5 message
digest algorithm. First the passphrase and salt are hashed together,
yielding an MD5 message digest. Then a new digest is constructed,
hashing together the passphrase, the salt, and the first digest, all in
a rather complex form. Then this digest is passed through a thousand
iterations of a function which rehashes it together with the passphrase
and salt in a manner that varies between rounds. The output of the last
of these rounds is the resulting passphrase hash.
In the crypt() function the raw hash output is then represented in ASCII
as a 22-character string using a base 64 encoding. The base 64 digits
are "B<.>", "B</>", "B<0>" to "B<9>", "B<A>" to "B<Z>", "B<a>" to "B<z>"
(in ASCII order). Because the base 64 encoding can represent 132 bits
in 22 digits, more than the 128 required, the last digit can only take
four of the base 64 digit values. An additional complication is that
the bytes of the raw algorithm output are permuted in a bizarre order
( run in 1.106 second using v1.01-cache-2.11-cpan-96521ef73a4 )