import base64
# 定义要加密的字符串
message = "Hello, World!"
# 将字符串转换为字节串
message_bytes = message.encode('utf-8')
# 对字节串进行Base64加密
encoded_bytes = base64.b64encode(message_bytes)
# 将加密后的字节串转换为字符串
encoded_string = encoded_bytes.decode('utf-8')
print("加密后的结果:", encoded_string)
# 对加密后的字符串进行Base64解密
decoded_bytes = base64.b64decode(encoded_string.encode('utf-8'))
# 将解密后的字节串转换为字符串
decoded_string = decoded_bytes.decode('utf-8')
print("解密后的结果:", decoded_string)
欢迎光临 精易论坛 (https://125.confly.eu.org/) | Powered by Discuz! X3.4 |