I'd go with moritz's solution and simply use Digest::SHA1::sha1_base64(), but just in case you want to know why your attempt didn't work, here's why:
$sha->add(@ascii);
should've been
$sha->add(encode_utf8($x));
You just need to add the (UTF-8) string itself, not a list of stringified byte values such as "112", "97", "115"... (i.e. you did compute the digest of the string "11297115115119111114100").
Also, in your Java code, you're printing out the digest as signed bytes. To get the same behaviour in Perl, you'd need to
@z = unpack("c*",$sha->digest);
which would then print out as expected (when adding spaces for better readability (print "@z\n") ):
91 -86 97 -28 -55 -71 63 63 6 -126 37 11 108 -8 51 27 126 -26 -113 -40
In reply to Re^3: Convert Java to Perl -> Script attached
by almut
in thread Convert Java to Perl -> Script attached
by smoky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |