python 数据加密测试 -base64

#!/usr/bin/env Python3
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @virtualenv:workon
# @contact: 1040691703@qq.com
# @Desc:Code descripton
__author__ = '未昔/AngelFate'
__date__ = '2020/4/28 12:58'

import base64

test = 'hello, world'
# 加密
bs = base64.b64encode(test.encode("utf8"))
print(bs)

# 解密
decode = base64.b64decode(bs)
print(decode)
print(decode.decode("utf8"))

"""
python3 输入的都是 二进制 byte类型
注意:用于base64编码的,要么是ASCII包含的字符,要么是二进制数据
base64 是对称加密
"""
b'aGVsbG8sIHdvcmxk'
b'hello, world'
hello, world

Process finished with exit code 0