1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# -*- coding: utf-8 -*-
'''
Build in routines and classes to simplify encoding routines
'''
# Import python libs
import base64
import binascii
def hex_encode(data):
'''
Hex encode data
'''
return binascii.hexlify(data)
def hex_decode(data):
'''
Hex decode data
'''
return binascii.unhexlify(data)
def base16_encode(data):
'''
Base32 encode data
'''
return base64.b16encode(data)
def base16_decode(data):
'''
Base16 decode data
'''
return base64.b16decode(data)
def base32_encode(data):
'''
Base16 encode data
'''
return base64.b32encode(data)
def base32_decode(data):
'''
Base32 decode data
'''
return base64.b32decode(data)
def base64_encode(data):
'''
Base16 encode data
'''
return base64.b64encode(data)
def base64_decode(data):
'''
Base32 decode data
'''
return base64.b64decode(data)
|