Mojolicious::Plugin::Bcrypt(3pm)

Mojolicious::Plugin::Bcrypt3pm

Bcrypt your passwords!

Usage

Provides a helper for crypting and validating passwords via bcrypt.

    use Mojolicious::Plugin::Bcrypt;
    sub startup {
        my $self = shift;
        $self->plugin('bcrypt', { cost => 4 });
    }
    ...

Optional parameter "cost" is a non-negative integer controlling the cost of the hash function. The number of operations is proportional to 2^cost. The current default value is 6.

Version

Version 0.04

Helpers

bcrypt

Crypts a password via the bcrypt algorithm.

    $self->bcrypt( $password, $settings );

$settings is an optional string which encodes the algorithm parameters, as described in Crypt::Eksblowfish::Bcrypt.

    sub signup {
        my $self = shift;
        my $crypted_pass = $self->bcrypt( $self->param('password') );
        ...
    }

bcrypt_validate

Validates a password against a crypted copy (for example from 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
            ...;
        }
    }

Development and repository

Clone it on GitHub at https://github.com/naturalist/Mojolicious--Plugin--Bcrypt

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8–9
  2. 10–11
  3. 12–13

Author

Stefan G., "<minimal at cpan.org>"

From libmojolicious-plugin-bcrypt-perl 0.14-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.