Python is a high level general purpose programming language which supports several programming paradigms, including object-oriented, functional, structural, imperative, and aspect-oriented. The main architectural features of Python are dynamic typing, automatic memory management, full introspection, exception handling mechanism, multi-thread computing, and convenient high-level data structures. The standard library includes a bundle of useful functions, including the
base64 module that allows encoding and decoding data using several Base64 algorithms.
To encode data to Base64 in Python, use the function base64.b64encode:
from base64 import b64encode print(b64encode('guru')) #-> 'Z3VydQ=='
And of course, the reverse process — to decode Base64 values use the function base64.b64decode:
from base64 import b64decode print(b64decode('Z3VydQ==')) #-> 'guru'
Everything is quite simple, but if you are looking for some useful examples, check the following ones: