Crypt::PasswdMD5(3)

πŸ‘‘ Crypt::PasswdMD5(3)

Okay so bestie, real talk: you're looking at the User Contributed Perl Documentation page for Crypt::PasswdMD5, and it's genuinely a little gem. It gives you MD5-based crypt() functions that actually interoperate with the rest of the world, which is giving "I play well with others" main character energy. πŸ’–


✨ NAME ✨

Crypt::PasswdMD5 β€” provides interoperable MD5-based crypt() functions. That's it, that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

First lil' taste, using the default exports:

        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, if you wanna pull in the salt generator yourself:

        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.

Lowkey obsessed with how tidy that is. πŸ¦‹


πŸ’… DESCRIPTION πŸ’…

apache_md5_crypt() gives you a function compatible with Apache's .htpasswd files. This one was contributed by Bryan Hart <bryan@eai.com> β€” shoutout, icon. πŸ’œ This function is exported by default.

unix_md5_crypt() gives you 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 β€” yes, that's literally the version string, don't come for me. πŸ’€ 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(). That function is not exported by default, so you gotta ask for it. πŸ™ˆ


πŸ”₯ LICENSE AND WARRANTY πŸ”₯

This code and all accompanying software comes with NO WARRANTY. You use it at your own risk. No cap, no take-backs, no "but bestie I thought you had me". 😭

This code and all accompanying software can be used freely under the same terms as Perl itself. Slay. πŸ’…


⭐ METHODS ⭐

πŸ“ apache_md5_crypt($password, $salt)

This sets a magic variable, and then passes all the calling parameters to unix_md5_crypt($password, $salt). Magic variable! Very mysterious, very witchy. 🧚

Returns an encrypted version of the given password.

Basically, it's a very poor choice for anything other than password authentication. Like, don't repurpose it for your art project, it said what it said. πŸ’€

πŸŽ€ random_md5_salt([$length])

Here, [] indicate an optional parameter. (The brackets, not the salt. The salt is not optional-bracketed, it's just salt.)

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. Same warning, same energy, fr fr. ✨


πŸ¦‹ 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>

Go off, file that issue, be thorough, include the details. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Luis E. MuΓ±oz <luismunoz@cpan.org>.

Maintenance by Ron Savage <rsavage@cpan.org> as of V 1.40.


πŸ’€ Quick vibe check reminder, bestie: both crypt functions here are, per the docs, "a very poor choice for anything other than password authentication." That's a straight-up technical caveat, not a bit. Don't use them for general encryption. πŸ™

That's the whole page! 🌸 It's perl v5.42.0, dated 2026-05-23, and it's Crypt::PasswdMD5(3) β€” go forth, hash responsibly, and remember: random_md5_salt() maxes out at 8. Periodt. πŸ’…πŸ”₯

πŸ“¦ where this page comes from