Text to Zip to base64 and vice versa, in Python
<p>I have a 'text' that is converted to zip then converted to base64. How do I convert it back to plain text in python if I have that base64 value. ?</p>

<p>You convert the base 64 back, using <a href="https://docs.python.org/3.5/library/base64.html" rel="nofollow">base64 module</a>, and then the zip, using the <a href="https://docs.python.org/3.5/library/zipfile.html" rel="nofollow">zipfile module</a>.</p>

<p>Assuming <code>file.txt</code> was zipped into <code>file.zip</code>, and then the archive was converted to base 64 as <code>encoded.txt</code>:</p>

<pre><code>import zipfile
import base64
base64.decode(open('encoded.txt'), open('file.zip', 'w'))
ZipFile('file.zip').extractall()
plaintext = open('file.txt').read()
</code></pre>

python zip base64 zlib