python使用sha1加密方法验证文件的有效性,,import hashl
python使用sha1加密方法验证文件的有效性,,import hashl
import hashlib hash_new = hashlib.sha1() #或hashlib.md5() with open('driver.xml.tar.bz2','rb') as fp: #打开文件,一定要以二进制打开 while True: data = fp.read() #读取文件块 if not data: #直到读完文件 break hash_new.update(data) hash_value = hash_new.hexdigest() #生成40位(sha1)或32位(md5)的十六进制字符串 print hash_value
相关内容
- 批量去除UTF8的Bom标签,utf8bom标签,#!/usr/bin/p
- 周长画圆,周长,[Python]代码im
- for循环,,[Python]代码ki
- 格式化数字及其单位,格式化数字单位,[Python]代码de
- python socket单工聊天工具,pythonsocket单工,socket单工聊天
- 用Python编写的列举所有对称日的小程序--菜鸟写的,请
- python监控网卡流量,python监控网卡,[Python]代码im
- Find the coefficients of the polynomial that fits the specified data
- tinyipdate最新ip库 python操作类,tinyipdatepython,发布最新版
- Linux下歌词编辑器,Linux歌词编辑器,#!/usr/bin/e
评论关闭