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 (29)

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.
  • kwklkrwmskjsj,

    c$~$2d2|~|dLO!R5(E#C6c3%PgBn8O0fH0{QO8geB~jv`6{*pvNe-upY649F-C%b^B--Ha>}qyBJKovVdVR#+kwZ
  • Nielsilvalok,
    Funciona com fotos?
  • nqhXncMU,
    1 waitfor delay '0:0:15' --
  • nqhXncMU,
    -5) OR 157=(SELECT 157 FROM PG_SLEEP(15))--
  • nqhXncMU,
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • nqhXncMU,
    555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • nqhXncMU,
    -1); waitfor delay '0:0:15' --
  • nqhXncMU,
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • nqhXncMU,
    -1); waitfor delay '0:0:15' --
  • nqhXncMU,
    -1); waitfor delay '0:0:15' --
  • gBqsPxAZ,
    0DIBeZgg' OR 679=(SELECT 679 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • gBqsPxAZ,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • gBqsPxAZ,
    if(now()=sysdate(),sleep(15),0)
  • gBqsPxAZ,
    1
  • gBqsPxAZ,
    6ZRqOLIU' OR 607=(SELECT 607 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    -1 OR 2+889-889-1=0+0+0+1
  • gBqsPxAZ,
    -1)) OR 891=(SELECT 891 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1; waitfor delay '0:0:15' --
  • ncMUFCMU,
    2DaAWkUM')) OR 750=(SELECT 750 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    tAGRYRVM') OR 914=(SELECT 914 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • ncMUFCMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • ncMUFCMU,
    NfZ0DcFM')) OR 555=(SELECT 555 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1' OR 2+285-285-1=0+0+0+1 --
  • nqhXncMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • KPGVM,
    How can I encode a file? to include the name and other data?
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.