Different output after decode and encode data (base64)
<p>If i run:</p>

<pre><code>import base64
data = open('1.dat', 'rb').read()
decoded = base64.b64decode(data)
encoded = base64.b64encode(decoded)
data == encoded
</code></pre>

<p>I get "False" as result?
How to decode/encode to get the original result?</p>

<p>There is some flexibility in the way base64 is encoded, for example the insertion of newlines. There may also be some alternate characters which the <a href="https://docs.python.org/2/library/base64.html" rel="nofollow"><code>base64</code> module</a> allows you to specify when encoding and decoding. It's up to you to make sure the proper alternate characters are specified, but otherwise it's easy to compare two strings while ignoring any newlines or whitespace:</p>

<pre><code>''.join(data.split()) == ''.join(encoded.split())
</code></pre>

python base64