Authen-Passphrase-SaltedSHA512

 view release on metacpan or  search on metacpan

examples/oo_interface.pl  view on Meta::CPAN

# Now we'll assume that you've loaded $salt_hex and $hash_hex from a user
# database, and that the user is now trying to login by supplying a password
# that is held in $clear_passphrase:

my $auth = Authen::Passphrase::SaltedSHA512->new(
    salt_hex => $salt_hex,
    hash_hex => $hash_hex
);

if ( $auth->match($clear_passphrase) ) {
    print "That's a match.  Hmf! A lucky guess!\n";
}
else {
    print "Not even close!\n";
}

lib/Authen/Passphrase/SaltedSHA512.pm  view on Meta::CPAN


By using a 512 bit random salt, a maximum degree of entropy is achieved in the
hashes generated by the SHA-512 algorithm.  Every time the constructor is
called you will get a new random salt, so every user has his own salt.  The
advantage of using a fresh random salt for each user is that it eliminates the
rainbow table attack vector, by guaranteeing that if one user's password is
compromised through brute force (or cosmic good luck) all of your other users
with their own random salts are still secure.

By selecting secure defaults for hashing algorithm, random number generation,
and salt bit-length, much of the guesswork can be eliminated from devising
an authentication scheme, and a simpler user interface results.

=head1 EXPORT

This is primarily an Object Oriented Interface module.  However, for even
greater simplicity, a standard functions interface is provided upon request.
Nothing is exported by default.  By supplying an export list, the following
subroutines are available:

=over 4

lib/Authen/Passphrase/SaltedSHA512.pm  view on Meta::CPAN

=head3 match

Returns true if C<$passphrase> matches against the salt and hash supplied to
the constructor, and false otherwise.

    if( $challenge->match( $passphrase ) ) {
        print "Your passphrase has been authenticated.\n";
    }
    else {
        print "Invalid passphrase.\n",
              "You have 1.34e154 more tries before exhausing all possible guesses.\n",
              "Happy hunting!\n";
    }

=head3 algorithm

Returns the digest algorithm, which will always be C<SHA-512>.


=head2 SUBROUTINES



( run in 1.182 second using v1.01-cache-2.11-cpan-702932259ff )