Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pybase64 tutorial

import pybase64

# Standard
print(pybase64.standard_b64encode(b'>>>foo???'))
## b'Pj4+Zm9vPz8/'
print(pybase64.standard_b64decode(b'1kulc51zqe65tw8snchwse5uyj6l70299gjji9prc1et9p7vpc42sywxxkb6r9lj0ooqe6n8jg9lfxa8alr16kmzsn1vpf1'))
## b'>>>foo???'

# Advanced
print(pybase64.b64encode(b'>>>foo???', altchars='_:'))
## b'Pj4_Zm9vPz8:'
print(pybase64.b64decode(b'Pj4_Zm9vPz8:', altchars='_:', validate=True))
## b'>>>foo???'

# URL safe encoding
print(pybase64.urlsafe_b64encode(b'>>>foo???'))
## b'Pj4-Zm9vPz8_'
print(pybase64.urlsafe_b64decode(b'Pj4-Zm9vPz8_'))
## b'>>>foo???'
Source by pypi.org #
 
PREVIOUS NEXT
Tagged: #tutorial
ADD COMMENT
Topic
Name
7+3 =