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.

Edit
Report