NAME

PHP::Functions::Password - Perl ports of PHP password functions

DESCRIPTION

This module provides ported PHP password functions. This module only supports the bcrypt algorithm, as is the case with the equivalent PHP functions at the date of writing this. All functions may also be called as class methods and support inheritance too.

SYNOPSIS

use PHP::Functions::Password ();

Functional interface use:

use PHP::Functions::Password qw(password_hash);
my $password = 'secret';
my $crypted_string = password_hash($password);

Functional interface use, using options:

use PHP::Functions::Password qw(:all);
my $password = 'secret';
my $crypted_string = password_hash($password, PASSWORD_DEFAULT, cost => 11);

Class method use, using options:

use PHP::Functions::Password;
my $password = 'secret';
my $crypted_string = PHP::Functions::Password->hash($password, cost => 9);
# Note that the 2nd argument of password_hash() has been dropped here and may be specified
# as an option as should've been the case in the original password_hash() function IMHO.

EXPORTS

The following names can be imported into the calling namespace by request:

password_get_info
password_hash
password_verify
PASSWORD_BCRYPT
PASSWORD_DEFAULT
:all	- what it says
:consts	- the PASSWORD_* constants
:funcs	- the password_* functions

API

get_info($crypted)

The same as http://php.net/manual/en/function.password-get-info.php with the exception that it returns the following additional keys in the result:

algoSig	e.g. '2y'
salt
hash

Returns either a hash or a hashref depending on the context.

password_get_info($crypted)

Exportable alias of get_info($crypted).

hash($password, %options)

The same as http://php.net/manual/en/function.password-hash.php but without the $algo argument. The algorithm can be specified with the 'algo' option if necessary, since it is optional after all.

password_hash($password, $algo, %options)

Exportable proxy function for hash($password, %options) with the difference that this function uses the same argument structure as the PHP equivalent.

verify($password, $crypted)

The same as http://php.net/manual/en/function.password-verify.php.

password_verify($password, $hash)

Exportable alias of verify($password, $crypted).

SEE ALSO

Crypt::Eksblowfish::Bcrypt from which several internal functions were copied and slightly modified, Crypt::Eksblowfish used for creating/verifying crypted strings in bcrypt format, Crypt::OpenSSL::Random used for random salt generation.

COPYRIGHT

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

AUTHOR

Craig Manley (craigmanley.com)