Why am I getting this output from my function?
echo $var = hash_hmac('ripemd160', 'http://www.weburlhere.org', 0, 0);
echo "
";
echo $converted = base_convert($var, 16, 2);
echo "
";
Outputs:
407a9d8868a678e12d9fc0264f9ae11e8761b557
0000000000000000000000000000000000000000000000000000000000000000
Whereas base_convert($var, 16, 10)
outputs
1421821959848150668406846884086820088622688484226
correctly.
Also, as a side-question (bonus points for this!) I'm assuming ripemd160 gives me a unique identifier for each input preimage. I'm attempting to make a url-shortening service that shortens a URL from any length to its hash digest (I'm assuming converting the binary to base64 with base64_encode($converted)
will shorten the URL even more). Is this correct, and is this a good idea?