本文涉及两个加密方式hashlib和base64
# -*-coding:utf-8 -*-
# BY WANGCC
# 导入密码加密模块
import hashlib
import base64
#hashlib 加密
# 创建一个hash对象
h = hashlib.sha256()
# 填充要加密的数据
passwordstr = 'xxxx'
h.update(bytes(passwordstr, encoding='utf-8'))
# 获取加密结果
pawd_result = h.hexdigest()
print(pawd_result)
#base64加密
s = pawd_result
# 加密
bs = base64.b64encode(s.encode("utf8"))
print(bs)
网友评论