• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Crypt/Password/H21-Jan-2016-331120

t/H21-Jan-2016-14298

ChangesH A D21-Jan-20162.4 KiB12156

Changes.newH A D21-Jan-20162.4 KiB12156

LICENSEH A D21-Jan-201617.9 KiB380292

MANIFESTH A D21-Jan-2016278 1716

META.jsonH A D21-Jan-201618.1 KiB526524

META.ymlH A D21-Jan-201612.1 KiB394393

Makefile.PLH A D21-Jan-20161.3 KiB5847

READMEH A D21-Jan-20163.3 KiB9567

dist.iniH A D21-Jan-2016229 2013

weaver.iniH A D21-Jan-201621 21

README

1SYNOPSIS
2
3     use Crypt::Password::Util qw(
4         crypt
5         looks_like_crypt
6         crypt_type
7     );
8
9    Generating crypted password:
10
11     say crypt('pass'); # automatically choose the appropriate type and salt
12
13    Recognizing whether a string is a crypted password:
14
15     # return yes/no
16     say looks_like_crypt('62F4a6/89.12z');   # 1
17     say looks_like_crypt('foo');             # 0
18
19     # return the crypt type
20     say crypt_type('62F4a6/89.12z');                    # CRYPT
21     say crypt_type('$1$$...');                          # MD5-CRYPT
22     say crypt_type('$apr1$4DdvgCFk$...');               # MD5-CRYPT
23     say crypt_type('$5$4DdvgCFk$...');                  # SSHA256
24     say crypt_type('$6$4DdvgCFk$...');                  # SSHA512
25     say crypt_type('1a1dc91c907325c69271ddf0c944bc72'); # PLAIN-MD5
26     say crypt_type('$2a$08$TTSynMjJTrXiv3qEZFyM1.H9tjv71i57p2r63QEJe/2p0p/m1GIy2'); # BCRYPT
27     say crypt_type('foo');                              # undef
28
29     # return detailed information
30     my $res = crypt_type('$1$$oXYGukVGYa16SN.Pw5vNt/', 1);
31     # => {type=>'MD5-CRYPT', header=>'$1$', salt=>'', hash=>'oXYGukVGYa16SN.Pw5vNt/'}
32     $res = crypt_type('foo', 1);
33     # => undef
34
35DESCRIPTION
36
37    Crypt::Password::Util provides routines to: 1) generate crypted
38    password; 2) recognition of whether a string is a crypted password or
39    not, and its crypt type.
40
41    It recognizes several types of crypt methods:
42
43    # CODE: require Crypt::Password::Util; my $types =
44    \%Crypt::Password::Util::CRYPT_TYPES; print "=over\n\n"; for my $type
45    (sort keys %$types) { print "=item *
46    $type\n\n$types->{$type}{summary}.\n\nRecognized by:
47    $types->{$type}{re_summary}.\n\nMore info: $types-{$type}{link}>\n\n" }
48    print "=back\n\n";
49
50FUNCTIONS
51
52 looks_like_crypt($str) => bool
53
54    Return true if $str looks like a crypted password. If you want more
55    information instead of just a yes/no, use crypt_type().
56
57 crypt_type($str[, $detail]) => str|hash
58
59    Return crypt type, or undef if $str does not look like a crypted
60    password. Currently known types:
61
62    If $detail is set to true, will return a hashref of information
63    instead. This include type, as well as the parsed header, salt, etc.
64
65 crypt($str) => str
66
67    Try to create a "reasonably secure" crypt password with the support
68    available from the system's crypt().
69
70    Will first try to create a cost-based crypt, using rounds value that
71    will approximately take ~10ms (on my PC computer, an Intel Core i5-2400
72    CPU, that is) to create. This lets a server verify ~100 passwords per
73    second, which should be enough for many cases. On OpenBSD, will try
74    BCRYPT with cost=7. On other systems, will try SSHA512 with
75    rounds=15000.
76
77    If the above fails (unsupported by your crypt()), will fallback to
78    MD5-CRYPT (supported by NetBSD), then CRYPT. Will die if that also
79    fails.
80
81SEE ALSO
82
83    Authen::Passphrase which recognizes more encodings (but currently not
84    SSHA256 and SSHA512).
85
86    Crypt::Bcrypt::Easy to generate BCRYPT crypts on systems that do not
87    natively support it.
88
89    Crypt::PasswdMD5 to generate MD5-CRYPT crypts on systems that do not
90    natively support it.
91
92    Crypt::Password which also provides a routine to compare a password
93    with a crypted password.
94
95