一个简易的hash加密小工具源码,hash加密源码,一直喜欢密码相关的加密解
一个简易的hash加密小工具源码,hash加密源码,一直喜欢密码相关的加密解
一直喜欢密码相关的加密解密工作,感觉每破一个程序的时候,很有成就感。这是一个简易的hash加密小工具源码,是我在网络上搜集来的,感觉作者写的很有创意,很多地方值得我去学习。想让更多的朋友们看到,所以贴在编橙之家python学习平台这里。
#!/usr/bin/env python#-*-encoding = utf-8-*-# hasher.pyimport 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)) (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()#www.iplaypy.com
更多加密解密相关文章推荐:
Python实现DES加密算法源码例详解
Python迅雷快车旋风地址加密解密
编橙之家文章,
相关内容
- 计算前一个月最后一天日期的python方法,最后一天pyt
- python计算上个月第一天日期的方法,python上个月,pytho
- 计算上个月有多少天的python简单小程序,上个月python
- django实现获取用户输入方法,django实现获取用户,这是用
- python自动登录并备份文件操作,python自动登录备份,py
- Python发可以带附件的email操作方法分享,pythonemail,Pyth
- python面向过程的简单通讯录示例,python通讯录示例,初学
- Python数据库sqlite3的基本应用,python数据库sqlite3,Python数
- 显示py文件类名和函数的方法,py文件类函数,这是一个
- 下载游戏IP座标等信息的python方法,游戏ip座标python,下
评论关闭