Crypt::PasswdMD5(3pm)

Crypt::PasswdMD53pm

Provide interoperable md5-based crypt() functions

Usage

        use strict;
        use warnings;
        use Crypt::PasswdMD5;
        my($password)       = 'seekrit';
        my($salt)           = 'pepperoni';
        my($unix_crypted)   = unix_md5_crypt($password, $salt);
        my($apache_crypted) = apache_md5_crypt($password, $salt);
        Or:
        use strict;
        use warnings;
        use Crypt::PasswdMD5 'random_md5_salt';
        my($length) = 7;
        my($salt_1) = random_md5_salt($length);
        my($salt_2) = random_md5_salt(); # Default to $length == 8.

Overview

apache_md5_crypt() provides a function compatible with Apache's ".htpasswd" files. This was contributed by Bryan Hart <[email protected]>. This function is exported by default.

The unix_md5_crypt() provides a crypt()-compatible interface to the rather new MD5-based crypt() function found in modern operating systems. It's based on the implementation found on FreeBSD 2.2.[56]-RELEASE. This function is also exported by default.

For both functions, if a salt value is not supplied, a random salt will be generated, using the function random_md5_salt(). This function is not exported by default.

Methods

apache_md5_crypt($password, $salt)

This sets a magic variable, and then passes all the calling parameters to "unix_md5_crypt($password, $salt)".

Returns an encrypted version of the given password.

Basically, it's a very poor choice for anything other than password authentication.

random_md5_salt([$length])

Here, [] indicate an optional parameter.

Returns a random salt of the given length.

The maximum length is 8.

If $length is omitted, it defaults to 8.

unix_md5_crypt($password, $salt)

Returns an encrypted version of the given password.

Basically, it's a very poor choice for anything other than password authentication.

Repository

<https://github.com/ronsavage/Crypt-PasswdMD5.git>

Support

Bugs should be reported via the CPAN bug tracker at

<https://github.com/ronsavage/Crypt-PasswdMD5/issues>

License, and disclaimer

See the accompanying LICENSE file.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

Releases

13 releases since Debian 3.0 (Woody); the text changed 8 times.

  1. 3.0
  2. 3.1
  3. 4.0
  4. 5.0–6.0
  5. 7–9
  6. 10
  7. 11
  8. 12–13
  9. Arch

Author

Luis E. Muñoz <[email protected]>.

Maintenance by Ron Savage <[email protected]> as of V 1.40.

From perl-crypt-passwdmd5 1.46-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.