use Authen::Passphrase::Scrypt;
# Hash a password
- my $sc = Authen::Passphrase::Scrypt->new({
+ my $sc = Authen::Passphrase::Scrypt->new(
passphrase => 'correcthorsebatterystaple'
- });
+ );
my $hash = $sc->as_rfc2307;
say "The given password hashes to $hash";
say 'The password was "xkcd"' if $sc->match('xkcd');
# Advanced hashing
- my $sc = Authen::Passphrase::Scrypt->new({
+ my $sc = Authen::Passphrase::Scrypt->new(
passphrase => 'xkcd',
logN => 14, # General work factor
r => 16, # Memory work factor
p => 1, # CPU (parallellism) work factor
salt => 'SodiumChloride && sODIUMcHLORIDE', # Must be 32 bytes
- });
+ );
say 'The given password now hashes to ', $sc->as_rfc2307;
=head1 DESCRIPTION
=over
-=item Authen::Passphrase::Scrypt->B<new>(I<\%args>)
+=item Authen::Passphrase::Scrypt->B<new>(I<%args>)
Creates a new L<Authen::Passphrase::Scrypt> from a given passphrase
-and parameters. Use this to hash a passphrase. The arguments are:
+and parameters. Use this to hash a passphrase. This function takes
+either a key value list or a hashref. The arguments are:
=over
decrease logN and increase p; if scrypt uses too much CPU but not
enough memory, decrease logN and increase r.
+Note that C<< 2^logN >> must fit in 64 bits and C<< r * p < 2^30 >>.
+
=item $sc->B<as_rfc2307>
Returns the hash of the passphrase, in RFC2307 format. This is
otherwise.
=item Authen::Passphrase::Scrypt->from_crypt
+
=item $sc->as_crypt
These functions both croak. They are provided for compatibility with