I need to do SHA256 hashing of email addresses and I need the result as a String.
I tried the following:
use Digest::SHA qw(sha256);
my $data = 'swaranga@gmail.com';
my $digest = sha256($data);
print $digest;
But it prints something like:
B/D6i1μû^Þ©Q;¢Þ
I need the output as follows:
cbc41284e23c8c7ed98f589b6d6ebfd6
The above hash is generated using SHA256 generator of Apache DigestUtils.
What am I doing wrong? I am a newbie in perl, so excuse if it is something silly.
Thanks.
You probably want
Digest::SHA qw(sha256_hex)
From CPAN's Digest::SHA pagecbc41284e23c8c7ed98f589b6d6ebfd6
is MD5 forswaranga@gmail.com
, not SHA-256SHA encryptions for
swaranga@gmail.com
>>If you sure you want to use SHA-256 and you are looking for HEX output, then try this one:
Script:
or
Output:
And if you want MD5 with HEX output, then try this one:
Script:
or
Output: