use Some_RSA_Module; use Digest::MD5 qw/ md5 /; # decode base64 as before, then: my $encrypted = substr($cookie, -64); substr($cookie, -65) = ''; # strip the null and the security field my $checksum = Some_RSA_Module::unencrypt($some_public_key, $encrypted); my $new_checksum = md5($cookie); if ($new_checksum eq $checksum) { print "Checksums match, cookie data is valid.\n"; } else { print "Checksums don't match, cookie data has been tampered with.\n"; }