发布时间:2019-09-25 08:21:38编辑:auto阅读(1847)
把写内容过程中常用的内容段记录起来,下面的资料是关于使用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.
>>>
上一篇: python unix时间戳与正常时间转
下一篇: python nohup linux 后
47769
46278
37155
34658
29248
25909
24781
19884
19444
17939
5734°
6340°
5857°
5906°
7009°
5844°
5866°
6375°
6335°
7701°