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
- opensuse-leap 16.0: perl-Crypt-PasswdMD5 1.430.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms