python--base64--简单的加密和解密
import base64 a = "liming我是中国人" bytesString = a.encode(encoding="utf-8") # 转码--字符串转成字节形式的字符串 #b'liming\xe6\x88\x91\xe6\x98\xaf\xe4\xb8\xad\xe5\x9b\xbd\xe4\xba\xba' encodestr = base64.b64encode(bytesString) #加密--转换成base64编码 #参数:字节形式的字符串 #b'bGltaW5n5oiR5piv5Lit5Zu95Lq6' x=encodestr.decode() # 解码 # bGltaW5n5oiR5piv5Lit5Zu95Lq6 decodestr = base64.b64decode(encodestr) #解密 #b'liming\xe6\x88\x91\xe6\x98\xaf\xe4\xb8\xad\xe5\x9b\xbd\xe4\xba\xba' x=decodestr.decode() print(encodestr,decodestr,x)