Python 官方文档:入门教程 => 点击学习
把写内容过程中常用的内容段记录起来,下面的资料是关于使用python3的base64编解码实现字符串的简易加密解密的内容。 import base64 copyright = 'Copyright (c) 2012 Doucub
把写内容过程中常用的内容段记录起来,下面的资料是关于使用python3的base64编解码实现字符串的简易加密解密的内容。
import base64
copyright = 'Copyright (c) 2012 Doucube Inc. All rights reserved.'
def main():
#转成bytes string
bytesString = copyright.encode(encoding="utf-8")
print(bytesString)
#base64 编码
encodestr = base64.b64encode(bytesString)
print(encodestr)
print(encodestr.decode())
#解码
decodestr = base64.b64decode(encodestr)
print(decodestr.decode())
if __name__ == '__main__':
main()
输出结果
>>>
>>>
b'Copyright (c) 2012 Doucube Inc. All rights reserved.'
b'Q29weXJpZ2h0IChjKSAyMDEyIERvdWN1YmUgSW5jLiBBbGwGCmlnaHRzIHJlc2VydmVkLg=='
Q29weXJpZ2h0IChjKSAyMDEyIERvdWN1YmUgSW5jLiBBbGwgcmlnaHRzIHJlc2VydmVkLg==
Copyright (c) 2012 Doucube Inc. All rights reserved.
>>>
--结束END--
本文标题: 使用python3的base64编解码实
本文链接: https://www.lsjlt.com/news/192396.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0