perlancar > Crypt-Password-Util-0.12 > Crypt::Password::Util

Download:
Crypt-Password-Util-0.12.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.12   Source  

NAME ^

Crypt::Password::Util - Crypt password utilities

VERSION ^

This document describes version 0.12 of Crypt::Password::Util (from Perl distribution Crypt-Password-Util), released on 2015-01-31.

SYNOPSIS ^

 use Crypt::Password::Util qw(crypt_type looks_like_crypt crypt);

 say crypt_type('62F4a6/89.12z');                    # CRYPT
 say crypt_type('$1$$...');                          # MD5-CRYPT
 say crypt_type('$apr1$4DdvgCFk$...');               # MD5-CRYPT
 say crypt_type('$5$4DdvgCFk$...');                  # SSHA256
 say crypt_type('$6$4DdvgCFk$...');                  # SSHA512
 say crypt_type('1a1dc91c907325c69271ddf0c944bc72'); # PLAIN-MD5
 say crypt_type('$2a$08$TTSynMjJTrXiv3qEZFyM1.H9tjv71i57p2r63QEJe/2p0p/m1GIy2'); # BCRYPT
 say crypt_type('foo');                              # undef

 # return detailed information
 my $res = crypt_type('$1$$oXYGukVGYa16SN.Pw5vNt/', 1);
 # => {type=>'MD5-CRYPT', header=>'$1$', salt=>'', hash=>'oXYGukVGYa16SN.Pw5vNt/'}

 say looks_like_crypt('62F4a6/89.12z');   # 1
 say looks_like_crypt('foo');             # 0

 say crypt('pass'); # automatically choose the appropriate type and salt

DESCRIPTION ^

Crypt::Password::Util facilitates the generation and recognition of unix passwords as found in /etc/shadow on Unix/Linux systems and /etc/master.passwd on BSD systems. When using crypt(), it is possible several methods will be attempted before returning a result. This is done to insure that your system supports the selected hash type.

FUNCTIONS ^

crypt_type($str[, $detail]) => str|hash

Return crypt type, or undef if $str does not look like a crypted password. Currently known types:

If $detail is set to true, will return a hashref of information instead. This include type, as well as the parsed header, salt, etc.

looks_like_crypt($str) => BOOL

Return true if $str looks like a crypted password.

crypt($str) => STR

Like Perl's crypt(), but automatically choose the appropriate crypt type and random salt. Will first choose SSHA512 with 64-bit random salt. If not supported by system, fall back to MD5-CRYPT with 32-bit random salt. If that is not supported, fall back to CRYPT.

SEE ALSO ^

Authen::Passphrase which recognizes more encodings (but currently not SSHA256 and SSHA512).

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Crypt-Password-Util.

SOURCE ^

Source repository is at https://github.com/perlancar/perl-Crypt-Password-Util.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Crypt-Password-Util

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: