Mojolicious::Plugin::Scrypt - Scrypt salted password hashing for Mojolicious
# Mojolicious $self->plugin('Scrypt'); # Mojolicious::Lite plugin 'Scrypt';
$self->plugin( 'Scrypt', { salt_length => int, # default: 32 cost => int, # default: 16384 block_size => int, # default: 8 parallelism => int, # default: 1 derived_length => int, # default: 32 });
For more infomation see Crypt::ScryptKDF.
Mojolicious::Plugin::Scrypt module use Scrypt algorithm creates a password hash. Other encryption algorithms include Argon2 or PBKDF2, Bcrypt and more.
my $encoded = $app->scrypt($password);
Use random salt, default length 32.
# or use your salt my $salt = 'saltSalt'; my $encoded2 = $app->scrypt($password, $salt);
Do you want to generate salt?
Mojolicious::Plugin::Scrypt using Crypt::PRNG. You can use Crypt::PRNG::random_bytes(), Crypt::PRNG::random_string(), ...and more.
Crypt::PRNG::random_bytes()
Crypt::PRNG::random_string()
sub login { my $c = shift; my $password = $c->param('password'); my $encoded = get_hash_from_db(); if ( $c->scrypt_verify($password, $encoded) ){ # Correct ... } else { # Incorrect ... } }
$plugin->register(Mojolicious->new);
Register plugin in Mojolicious application.
Munenori Sugimura <clicktx@gmail.com>
Crypt::ScryptKDF, Mojolicious, Mojolicious::Guides, http://mojolicious.org.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Mojolicious::Plugin::Scrypt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Scrypt
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Scrypt
For more information on module installation, please visit the detailed CPAN module installation guide.