Mojoli...:Bcrypt(3pm)
π Mojolicious::Plugin::Bcrypt β the user-contributed Perl docs version, bestie π
okay so. real talk. this is a plugin for Mojolicious, and it does exactly one thing and it does it gorgeously: it bcrypts your passwords. that's it. that's the whole vibe. πβ¨
π NAME
Mojolicious::Plugin::Bcrypt β bcrypt your passwords! π
π·οΈ VERSION
Version 0.04
β¨ SYNOPSIS
so this gives you a helper for crypting passwords AND validating them, all via bcrypt. chef's kiss. π
use Mojolicious::Plugin::Bcrypt;
sub startup {
my $self = shift;
$self->plugin('bcrypt', { cost => 4 });
}
...
the optional parameter cost is a non-negative integer and it controls the cost of the hash function, iykyk. the number of operations is proportional to 2^cost. the current default value is 6. no cap. π«Ά
π§ HELPERS
π bcrypt
crypts a password via the bcrypt algorithm. iconic behaviour honestly.
$self->bcrypt( $password, $settings );
$settings is an optional string which encodes the algorithm parameters, as described in Crypt::Eksblowfish::Bcrypt. (yes bestie, go read that one too, it's giving lore.)
sub signup {
my $self = shift;
my $crypted_pass = $self->bcrypt( $self->param('password') );
...
}
β
bcrypt_validate
validates a password against a crypted copy β like, for example, the one chilling in your database. ποΈπ
sub login {
my $self = shift;
my $entered_pass = $self->param('password');
my $crypted_pass = $self->get_password_from_db();
if ( $self->bcrypt_validate( $entered_pass, $crypted_pass ) ) {
# Authenticated
...;
}
else {
# Wrong password
...;
}
}
π¨ important: notice it's $self->bcrypt_validate( $entered_pass, $crypted_pass ) β the plaintext goes FIRST, the crypted one goes SECOND. do not flip these. flipping these is the opposite of slaying.
π DEVELOPMENT AND REPOSITORY
clone it on GitHub at https://github.com/naturalist/Mojolicious--Plugin--Bcrypt
go. run. contribute. main character energy only. π
π SEE ALSO
Crypt::Eksblowfish::BcryptMojoliciousMojolicious::Plugin
π«Ά AUTHOR
Stefan G., <minimal at cpan.org>
π LICENSE AND COPYRIGHT
this program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
see http://dev.perl.org/licenses/ for more information.
and that's the whole page, bestie β written up against perl v5.36.0, dated 2022-11-19, and it's the Mojoli...:Bcrypt(3pm) user-contributed Perl documentation. now go hash something responsibly. mwah. ππ
π¦ where this page comes from
- debian bookworm: libmojolicious-plugin-bcrypt-perl 0.14-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmojolicious-plugin-bcrypt-perl 0.14-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmojolicious-plugin-bcrypt-perl 0.14-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmojolicious-plugin-bcrypt-perl 0.14-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmojolicious-plugin-bcrypt-perl 0.14-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms