标签:update import code 读取 content div hex date class
hashlib 文件校验
# for循环校验 import hashlib def check_md5(file): ret = hashlib.md5() with open(file, mode=‘rb‘) as f1: for line in f1: ret.update(line) return ret.hexdigest() print(check_md5(‘rock1‘)) print(check_md5(‘rock‘)) print(check_md5(‘rock1‘) == check_md5(‘rock‘)) # while循环每次读取1024字节校验 import hashlib def check_md5(file): ret = hashlib.md5() with open(file, mode=‘rb‘) as f1: while 1: content = f1.read(1024) if content: ret.update(content) else: break return ret.hexdigest() print(check_md5(‘rock1‘)) print(check_md5(‘rock‘)) print(check_md5(‘rock1‘) == check_md5(‘rock‘))
用户名动态加盐校验
import hashlib def check_md5(s=‘‘): # ret = hashlib.md5(‘w‘.encode(‘utf-8‘)) # print(s[::-2]) ret = hashlib.md5() ret.update(s[::-2].encode(‘utf-8‘)) ret.update(s.encode(‘utf-8‘)) return ret.hexdigest() print(check_md5(‘146123‘)) print(check_md5(‘146123‘)) print(check_md5(‘rock‘) == check_md
标签:update import code 读取 content div hex date class
原文地址:https://www.cnblogs.com/chen55555/p/10246688.html