python 加密算法sha和base64

# coding=utf-8
import base64
from 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=='

posted @ 2020-03-02 19:31  不带R的墨菲特  阅读(521)  评论(0编辑  收藏  举报