python3中hashlib模块的sha1加密
from hashlib import sha1 # 需要加密的字符串 pwd = "123" # 创建sha1对象 s1 = sha1() # 对s1进行更新 s1.update(pwd.encode()) # 加密处理 result = s1.hexdigest() # 结果是40位字符串:'40bd001563085fc35165329ea1ff5c5ecbdbbeef' print(result)