# coding=utf-8import base64from hashlib import sha1 sha= sha1()sha.update(b"aaa"+b"bbb") # 字符串相加等价于两次update# sha.update(b‘bbb‘)aa=sha.hexdigest() str=aa.encode(‘utf-8‘)bs64=base64.b64encode(str)print(bs64) #b‘NjhkODU3MmMyNjYyYjBmMDZmNzIzZDdkNTA3OTU0ZmIwMzhiODU1OA==‘#b‘NjhkODU3MmMyNjYyYjBmMDZmNzIzZDdkNTA3OTU0ZmIwMzhiODU1OA==‘
原文地址:https://www.cnblogs.com/SunshineKimi/p/12397557.html
时间: 2024-10-12 18:33:10