python 輸入加密的MD5值,並搜尋檔案中的原始值
阿新 • • 發佈:2018-12-16
此程式可以輸入一串MD5的值,並在指定的檔案中搜索到原始值。程式自有用處。
#輸入加密的MD5值,並搜尋檔案中的原始值 by qianxiao996 #部落格地址:https://blog.csdn.net/qq_36374896 #使用方法 #目錄下必須有一個名為字典的TXT檔案 #輸入32位的MD5 即可尋找出檔案中的原始值 import os import hashlib def curlmd5(src): m = hashlib.md5() m.update(src.encode('UTF-8')) return m.hexdigest() def exit(): if str == 'q': os._exit(0) path = os.path.abspath('字典.txt') str = input("請輸入32位的MD5值:") str=str.lower() def query(): for line in file.readlines(): line = line.decode("utf-8").strip("\r\n") src = curlmd5(line) if src == str: print('您的查詢結果為:%s' % line) os._exit(0) while True: while str!='': file = open(path, "rb") query() file.close() str = input("查詢結果為空,請重新輸入(q退出):") exit() str = input("請不要輸入空字元,請重新輸入(q退出):") exit()
小白學python,大神勿噴。