Crypt-Sodium-XS

 view release on metacpan or  search on metacpan

lib/Crypt/Sodium/XS/pwhash.pm  view on Meta::CPAN

  my $memlimit = pwhash_OPSLIMIT_MAX();

Same as L</OPSLIMIT_MAX>.

=head2 pwhash_OPSLIMIT_MIN

  my $memlimit = pwhash_OPSLIMIT_MIN();

Same as L</OPSLIMIT_MIN>.

=head2 pwhash_PASSWD_MAX

  my $hash_max_size = pwhash_PASSWD_MAX();

Same as L</PASSWD_MAX>.

=head2 pwhash_PASSWD_MIN

  my $hash_min_size = pwhash_PASSWD_MIN();

Same as L</PASSWD_MIN>.

=head2 pwhash_SALTBYTES

  my $salt_size = pwhash_SALTBYTES();

Same as L</SALTBYTES>.

=head2 pwhash_STRBYTES

  my $hash_string_size = pwhash_STRBYTES();

Same as L</STRBYTES>.

=head2 pwhash_STRPREFIX

  my $hash_string_prefix = pwhash_STRPREFIX();

Same as L</STRPREFIX>.

=head1 GUIDELINES FOR CHOOSING OPSLIMIT AND MEMLIMIT

Start by determining how much memory the function can use. What will be the
highest number of processes evaluating the function simultaneously (ideally, no
more than 1 per CPU core)? How much physical memory is guaranteed to be
available?

Set memlimit to the amount of memory you want to reserve for password hashing.

Then set opslimit to 3 and measure the time it takes to hash a password.

If this is way too long for your application, reduce memlimit, but keep
opslimit set to 3.

If the function is so fast that you can afford it to be more computationally
intensive without any usability issues, then increase opslimit.

For online use (e.g. logging in on a website), a 1 second computation is likely
to be the acceptable maximum.

For interactive use (e.g. a desktop application), a 5 second pause after having
entered a password is acceptable if the password doesn’t need to be entered
more than once per session.

For non-interactive and infrequent use (e.g. restoring an encrypted backup), an
even slower computation can be an option.

However, the best defense against brute-force password cracking is to use
strong passwords.

=head1 SEE ALSO

=over 4

=item L<Crypt::Sodium::XS>

=item L<https://doc.libsodium.org/password_hashing>

=back

=head1 FEEDBACK

For reporting bugs, giving feedback, submitting patches, etc. please use the
following:

=over 4

=item *

RT queue at L<https://rt.cpan.org/Dist/Display.html?Name=Crypt-Sodium-XS>

=item *

IRC channel C<#sodium> on C<irc.perl.org>.

=item *

Email the author directly.

=back

=head1 AUTHOR

Brad Barden E<lt>perlmodules@5c30.orgE<gt>

=head1 COPYRIGHT & LICENSE

Copyright (c) 2022 Brad Barden. All rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut



( run in 0.564 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )