MD5哈希(校验和)验证工具
MD5-Checksum-verifier的Python项目详细描述
它用于检查与来自Internet的哈希一起存储的文件
- 使用
pip install md5-checksum-verifier
安装
功能:
fromhash-toolimportverifytoolverifytool.validHash('md5-hash-here')#this will return True when a hash is valid, and false if invalid (this just checks if it is in the format of an md5 hash)verifytool.genhash('filenamehere')#this will generate and return the hash of a fileverifytool.validate('hash','original file source via the internet')
示例使用:
fromhash-toolimportverifytooltry:localFile=verifytool.genhash('text.txt')#generates and stores the hashifverifytool.validHash(localFile)==True:try:ifverifytool.validate(localFile,'https://web.org/test-original.txt')==True:print("File has not been tampered with")except:print("Invalid hash - file may have been tampered with")else:print("Issue generating hash")except:print("Issue generating hash")