Python--加密小练习,,# 签名 为了防止作
Python--加密小练习,,# 签名 为了防止作
# 签名 为了防止作弊
# 1.用户设备号码MD5加密一次
# 2.再取加密后的前10位
# 3.再加盐,再给他md5一次
# 4.生成一个字符串
from hashlib import md5
class GetSign(object):
slat = ‘WSL234_#$%_12‘
def __init__(self, device_id):
self.device_id = device_id
def md5_str(self, str1):
s = str1.encode()
m = md5(s)
return m.hexdigest()
@property # 把这个函数变成一个属性方法,如果这个方法没有入参,那就可以给变成一个属性方法
def get_res(self):
first_md5 = self.md5_str(self.device_id)
tmp = first_md5[:10] # 取前10位
after_salt = tmp + self.slat
self.sign = self.md5_str(after_salt)
return self.sign
res = GetSign(‘12321321312321421412asdsad‘)
print(res.get_res)
Python--加密小练习
相关内容
- python __xx__的定义和用处,,python 对象的
- python----反射,,class foo:
- python--os,,os.listdir
- Python——内置方法,,内置的类方法 和内置
- 在线 Python运行工具,, 摘要准备PHP环境
- python sublime3 [Decode error - output not utf-8] 中文显示问题,
- Python 模拟postman上传文件,,最近工作需求:写的程
- python selenium 自动化测试图片识别1,,本人纯野生测试猿
- 【Python requests多页面爬取案例】 񩲝,,原文:
- python 使用 matplotlib.pyplot来画柱状图和饼图,,导入包i
评论关闭