I am trying to generate a hash value using this code
use Digest::SHA qw(sha1_hex); print sha1_hex("prady@prady.com")
The generated value is
642732893b7d25cf6a47773fa1c4988fac2ff3ad
When i check the hash code using the free generator
http://sha1-hash-online.waraxe.us/
i get the hash code as
e49ece87a60590483bb74c24e82f9d64d13d98c1
I performed the same test by removing the @ symbol from the string
i get matching values from the website as well as the code.
Both return me the same hash code
08e1698b5818d8fdf0f7b31132c3b44c49671644
Of the ones generated by the code and website which is the correct one ? Is this a known behavior while using @ symbol on string ?
Using
@somethinginside a double-quoted string is interpreted as an array name by Perl. You would have caught that mistake if you’d useduse warnings;anduse strict;. The solution is simple: escape the@, like this:print sha1_hex("some\@where.org"). Or use single-quoted strings.