Crypt::Bcrypt - A modern bcrypt implementation
version 0.001
use Crypt::Bcrypt qw/bcrypt bcrypt_check/; my $hash = bcrypt($password, '2b', 12, $salt); if (bcrypt_check($password, $hash)) { ... }
This module provides a modern and user-friendly implementation of the bcrypt password hash.
Note that in bcrypt passwords may only contain 72 characters.
This computes the bcrypt hash for $password in $subtype, with $cost and $salt.
$password
$subtype
$cost
$salt
Valid subtypes are:
2b
This is the subtype the rest of the world has been using since 2014, you should use this unless you have a very specific reason to use something else.
2a
This is an old and subtly buggy version of bcrypt. This is mainly useful for Crypt::Eksblowfish compatibility.
2y
This type is considered equivalent to 2b, and is only commonly used on php.
2x
This is a very broken version that is only useful for compatibility with ancient php versions.
$cost must be between 5 and 31 (inclusive). $salt must be exactly 16 bytes.
This checks if the $password satisfies the $hash, and does so in a timing-safe manner.
$hash
Crypt::Eksblowfish::Bcrypt also offers bcrypt, but only supports the 2a subtype.
Leon Timmermans <leont@cpan.org>
This software is copyright (c) 2021 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Crypt::Bcrypt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::Bcrypt
CPAN shell
perl -MCPAN -e shell install Crypt::Bcrypt
For more information on module installation, please visit the detailed CPAN module installation guide.