A virtual teacher who reveals to you the great secrets of Base64

Python Base64

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:

Comments (2)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • Pablo,
    Awesome content, thank you
    • Administrator,
      Hello Pablo,
      Thank you for kind words. I'm glad you like it.
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.