精易论坛

标题: python中base64的例子 [打印本页]

作者: realpc    时间: 2023-12-16 16:49
标题: python中base64的例子
[Python] 纯文本查看 复制代码
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)


作者: 文西哥    时间: 2023-12-16 17:18
大佬就是大佬,学习一下,谢谢大佬分享
作者: zyg666    时间: 2023-12-16 17:44
学习了最近正在学习,膜拜大佬




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4