Crypt-Bcrypt
view release on metacpan or search on metacpan
123456789101112131415161718use
warnings;
use
strict;
use
Test::More;
use
Crypt::Bcrypt
qw/bcrypt bcrypt_check bcrypt_prehashed bcrypt_check_prehashed bcrypt_needs_rehash/
;
sub
de_base64($) {
my
(
$text
) =
@_
;
$text
=~
tr
#./A-Za-z0-9#A-Za-z0-9+/#;
return
decode_base64(
$text
);
}
my
$password
=
"Hello World,"
;
my
$salt
=
"A"
x 16;
my
$hash1
= bcrypt(
$password
,
"2b"
, 12,
$salt
);
1234567891011121314151617181920use
warnings;
use
strict;
use
Test::More;
sub
de_base64($) {
my
(
$text
) =
@_
;
$text
=~
tr
#./A-Za-z0-9#A-Za-z0-9+/#;
return
decode_base64(
$text
);
}
my
@wrong_passwords
=
qw(foo quux supercalifragilisticexpialidocious)
;
while
(<DATA>) {
chomp
;
my
(
$settings
,
$hash
,
$password
) =
split
' '
,
$_
;
my
(
$type
,
$cost
,
$encoded_salt
) =
$settings
=~ / ^ \$ (2\w?) \$ (\d+) \$ (.*) $ /x or
die
$settings
;
( run in 0.249 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )