python写几种base加解密

源代码

import base64

def b64encode(basec):
    PlainText = basec.encode("utf-8")
    a = base64.b64encode(PlainText)
    CipherText = a.decode("utf-8")
    return CipherText

def b64decode(plain):
    CipherText = plain.encode("utf-8")
    cipher = base64.b64decode(CipherText)
    PlainText = cipher.decode("utf-8")
    return PlainText

def b32encode(basec):
    PlainText = basec.encode("utf-8")
    a = base64.b32encode(PlainText)
    CipherText = a.decode("utf-8")
    return CipherText

def b32decode(plain):
    CipherText = plain.encode("utf-8")
    cipher = base64.b32decode(CipherText)
    PlainText = cipher.decode("utf-8")
    return PlainText

def b16encode(basec):
    PlainText = basec.encode("utf-8")
    a = base64.b16encode(PlainText)
    CipherText = a.decode("utf-8")
    return CipherText

def b16decode(plain):
    CipherText = plain.encode("utf-8")
    cipher = base64.b16decode(CipherText)
    PlainText = cipher.decode("utf-8")
    return PlainText

你可能感兴趣的:(python写几种base加解密)