I sent an e-mail which included almost 2500 characters of text and one attached 60KiB PNG file. This text included number 185 eight times. However, after the e-mail was encoded to base64 and sent, I'm able to find only three "MTg1"("MTg1" is "185" in base64 encoding) strings from e-mail source. How to explain this? According to e-mail header, content type is "text/plain; charset=UTF-8" and content transfer encoding is "base64".
Base64 encoding turns 6 bytes into 8. There are 3 possible encodings for any given plaintext, shifted by several bits each time (and mixed with other encoded text, hence not trivial to find).
>>> '185'.encode('base64') 'MTg1\n' >>> '\x00185'.encode('base64') 'ADE4NQ==\n' >>> '\x00\x00185'.encode('base64') 'AAAxODU=\n' >>> '\x00\x00\x00185'.encode('base64') 'AAAAMTg1\n'