I have a script to convert to base 62 (A-Za-z0-9) but how do I get a number out of MD5?
I have read in many places that because the number from an MD5 is bigger than
You could use a slightly modified Base 64 with -
and _
instead of +
and /
:
function base64_url_encode($str) {
return strtr(base64_encode($str), array('+'=>'-', '/'=>'_'));
}
function base64_url_decode($str) {
return base64_decode(strtr($str, array('-'=>'+', '_'=>'/')));
}
Additionally you could remove the trailing padding =
characters.
And to get the raw MD5 value (binary string), set the second parameter (named $raw_output
in the manual) to true:
$raw_md5 = md5($str, true);