The base64 module contains functions for translating binary data into a subset of ASCII suitable for transmission using plaintext protocols.
Super set of binascii
and struct
Almost a wrapper around struct and binascii. Implementation can be found at /usr/lib/python3.5/base64.py
In [1]:
import base64
In [2]:
string = 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t'
decode_string = base64.b64decode(string)
decode_string.decode('ascii')
Out[2]:
In [3]:
# this wont work:string = 'this is a regular ascii string that we will convert to base32'
string = string.encode('utf-8')
print(len(string))
base64.b32encode(string)
Out[3]:
In [ ]:
In [ ]: