1Crypt::PasswdMD5(3) User Contributed Perl Documentation Crypt::PasswdMD5(3)
2
3
4
6 Crypt::PasswdMD5 - Provide interoperable MD5-based crypt() functions
7
9 use strict;
10 use warnings;
11
12 use Crypt::PasswdMD5;
13
14 my($password) = 'seekrit';
15 my($salt) = 'pepperoni';
16 my($unix_crypted) = unix_md5_crypt($password, $salt);
17 my($apache_crypted) = apache_md5_crypt($password, $salt);
18
19 Or:
20
21 use strict;
22 use warnings;
23
24 use Crypt::PasswdMD5 'random_md5_salt';
25
26 my($length) = 7;
27 my($salt_1) = random_md5_salt($length);
28 my($salt_2) = random_md5_salt(); # Default to $length == 8.
29
31 "apache_md5_crypt()" provides a function compatible with Apache's
32 ".htpasswd" files. This was contributed by Bryan Hart <bryan@eai.com>.
33 This function is exported by default.
34
35 The "unix_md5_crypt()" provides a crypt()-compatible interface to the
36 rather new MD5-based crypt() function found in modern operating
37 systems. It's based on the implementation found on FreeBSD
38 2.2.[56]-RELEASE. This function is also exported by default.
39
40 For both functions, if a salt value is not supplied, a random salt will
41 be generated, using the function random_md5_salt(). This function is
42 not exported by default.
43
45 This code and all accompanying software comes with NO WARRANTY. You use
46 it at your own risk.
47
48 This code and all accompanying software can be used freely under the
49 same terms as Perl itself.
50
52 apache_md5_crypt($password, $salt)
53 This sets a magic variable, and then passes all the calling parameters
54 to "unix_md5_crypt($password, $salt)".
55
56 Returns an encrypted version of the given password.
57
58 Basically, it's a very poor choice for anything other than password
59 authentication.
60
61 random_md5_salt([$length])
62 Here, [] indicate an optional parameter.
63
64 Returns a random salt of the given length.
65
66 The maximum length is 8.
67
68 If $length is omitted, it defaults to 8.
69
70 unix_md5_crypt($password, $salt)
71 Returns an encrypted version of the given password.
72
73 Basically, it's a very poor choice for anything other than password
74 authentication.
75
77 Bugs should be reported via the CPAN bug tracker at
78
79 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-PasswdMD5>
80
82 Luis E. Muñoz <luismunoz@cpan.org>.
83
84 Maintenance by Ron Savage <rsavage@cpan.org> as of V 1.40.
85
86
87
88perl v5.28.1 2013-09-30 Crypt::PasswdMD5(3)