[Melbourne-pm] Newbie crypto/bcrypt question
Alfie John
alfiej at fastmail.fm
Thu May 22 23:26:25 PDT 2014
Hi guys,
Playing around with crypto and found the following weird. Can anyone
explain why bcrypt_hash() is returning the same hashes for different
plain-texts?
Alfie
-- 8< --
#!/usr/bin/perl
use strict;
use warnings;
use Crypt::Eksblowfish::Bcrypt qw{bcrypt_hash en_base64};
my @A = hashPassword("abc");
my @B = hashPassword("abcabc");
printf("hash: %s, base64(hash): %s\n",
($A[0] eq $B[0]) ? "EQUAL" :"DIFFERENT",
($A[1] eq $B[1]) ? "EQUAL" : "DIFFERENT",
);
sub hashPassword {
my ($password) =@_;
my $passwordHash = bcrypt_hash(
{
key_null => 1,
cost => 8,
salt => "mySecretSaltSalt",
},
$password,
);
return ($passwordHash, en_base64($passwordHash));
}
--
Alfie John
alfiej at fastmail.fm
More information about the Melbourne-pm
mailing list