Suppose you have a MD5 hash encoded in base64. Then each
character needs only 6 bits to store each character in the
resultant 22-byte string (excluding the ending ‘==’). Thus, each
base64 md5 hash can shrink down to 6*22 = 132 bits, which
requires 25% less memory space compared to the original 8*22=176
bits string.
Is there any Python module or function that lets you store base64
data in the way described above?
David gave an answer that works on all base64 strings.
Just use
in base64 module. That is,
is a more memory efficient representation of the original base64 string. If you
are truncating trailing ‘==’ in your base64 md5, use it like