I am looking for a way to convert MD5 and SHA1 hashes from their binary to hex representations and vice versa. I want to do it in Perl but a common explaination is welcome too.
use Digest::MD5 qw(md5 md5_hex md5_base64);
$data = "Plaintext";
$digest_bin = md5($data);
$digest_hex = md5_hex($data);
How can I compare $digest_bin and $digest_hex and make sure that they are hashes of the same $data?
If you look into the source of Digest::MD5::Perl, which is the pure perl version of Digest::MD5, you’ll see:
So you can do: