hash加密小工具,hash加密工具,[Python]代码#!
hash加密小工具,hash加密工具,[Python]代码#!
[Python]代码
#!/usr/bin/env python#-*-encoding = utf-8-*-# hasher.py#@By:dengyongkaiimport sysimport hashlibimport linecachedef alglist(): print """ (1)MD5 (4)SHA256 (2)SHA1 (5)SHA384 (3)SHA224 (6)SHA512 """class hasher(object): def single(self): try: alglist() alg = raw_input("Select an algorithm:") functions = {"1":hashlib.md5,"2":hashlib.sha1,'3':hashlib.sha224,'4':hashlib.sha256,'5':hashlib.sha384,'6':hashlib.sha512} if alg in functions.keys(): hashob = functions[alg]() outfile = raw_input("Enter output file:") while 1: word = raw_input("Enter string: ") hashob.update(word) hashword = hashob.hexdigest() hashlst = open(outfile, 'a+') hashlst.write(hashword + '\n') print '[*] Output successful...' raw_input("[*] Press Return to continue OR 'Ctrl-C' to Quit...") else: alglist() print "[*] Your input not found..." sys.exit(1) except KeyboardInterrupt:# main() raise except IOError: print "[*] Input file not found..." sys.exit(1)# hasher.single() def hashlist(self): try: alglist() alg = raw_input("Select an algorithm:") functions = {'1':hashlib.md5, '2':hashlib.sha1, '3':hashlib.sha224, '4':hashlib.sha256, '5':hashlib.sha384, '6':hashlib.sha512} if alg in functions.keys(): hashob = functions[alg]() infile = raw_input("Enter input file:") outfile = raw_input("Enter output file:") count = len(open(infile).readlines()) i = 1 while i <= count + 1: word = linecache.getline(infile,i) hashob.update(word) hashword = hashob.hexdigest() outlist = open(outfile,'a++') outlist.write(hashword+'\n') i += 1 print "[*]Output successful..." raw_input("Press enter to return to the main menu OR 'Ctrl-C' to Quit...") main() else: alglist() print "[*] Your input not found..." sys.exit(1) except KeyboardInterrupt:# main() raise except IOError: print "[*] Input file not found..." sys.exit(1)# main()def main(): try: print """ O)) O)) O)) O)) O)))) O)) O)) O)) O)) O)) O) O) O)) O)) O)) O) O) O)) O)) O) O)) O)) O)) O)) O))O)) O)) O))) O)) O))O)) O))O))))) O)) O)) O)) O) O))O)) O)) O))O) O)) O)) O))O) O)) O)) O)) O)) O)) O)))O)0)O))O)) O)) O)) O)))) O))) O)) O)) http://blog.sina.com.cn/kaiyongdeng (1) Single Mode - Enter strings to be hashed one by one (2) List Mode - Input a text file of strings to be hashed""" mode = raw_input("Select a mode:") if mode == '1': hasher.single() elif mode == '2': hasher.hashlist() else: main() except KeyboardInterrupt: print "\n[*] Exiting..." sys.exit(1)if __name__ == "__main__": hasher = hasher() main()
相关内容
- 子网掩码转换,东施效颦之作啊,东施效颦之作,子网掩
- 批量调整指定目录下图片宽高,指定目录图片,[Python]代
- 代码去开头数字,代码开头数字,[Python]代码t=
- python reportlab 生成中文PDF范例,pythonreportlab,df -h 命令内
- 实现移位密码(凯撒密码)加密算法(两种方法),凯
- python glob 用通配符查找指定目录中的文件,,[Python]代码
- 使用python smtplib库发邮件添加cc,bcc,smtplibbcc,[Python]代
- Python分割文件,python分割,[Python]代码#e
- 自动登录网络设备备份配置文件 version0.2版本,自动登
- 学习和分享,学习分享,[Python]代码#-
评论关闭