I'm trying to represent the result of an MD5 hash in the shortest possible string. It seems a waste to just turn it into a hex string and let G through Z go to waste.
One idea I have had is getting the MD5 hash of my input as an array of bytes and constructing a BigInt
with it. I can then call toString(36)
, and get the number as a base-36 in a string (-?[0-9a-z]*
, the number can be positive or negative). It works for me.
Problem is, I'm not sure that a BigInt
can be constructed with any array of bytes, and I can't prove it with testing (at least not in a timely way!). I assume so, because I understand that a BigInt can be of arbitrary size. I can't use this method until I know for sure that it will work for all possible outputs. So, can anyone tell me whether it will work for all inputs (or how to easily convert a byte array so it can be represented in base 36).
Clarification: I have the implementation, I'm asking about the behaviour over the whole domain (i.e. 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)