Python实现的hash加密小工具详解编程语言
2023-06-13 09:20:23 时间
# hasher.py
[email protected]:dengyongkai
import sys
import hashlib
import linecache
def 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)
(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)
相关文章
- 工具推荐|面向气候研究者的Python可视化工具
- python求逆矩阵的方法,Python 如何求矩阵的逆「建议收藏」
- pycharm中使用anaconda部署python环境_pycharm怎么用anaconda的环境
- python中bool函数_bool()函数以及Python中的示例
- 30个Python小游戏,上班摸鱼我能玩一天【内附源码】
- python 实现一个自定义上下文管理器
- python字符串拼接
- 【说站】Python位置索引的介绍
- 什么是双因素验证 2FA,如何用 Python 实现?
- 万字长文告诉新手如何学习Python图像处理(上篇完结 四十四) | 「Python」有奖征文
- ArcGIS Pro创建python脚本工具
- python分段线性插值_Python实现分段线性插值
- Python 异步: 使用和查询任务(8)
- python>>numpy包
- python时间函数整理
- 如何用Python内置模块构建简单的REST服务、RPC服务
- 3.7k stars Python实现的地理编码测量距离查询工具
- python工具——Faker详解编程语言
- 安装Python MySQL驱动之快速指南(python安装mysql驱动)
- Python脚本实现Linux系统管理及自动化部署(python写linux)
- Linux环境下Python开发的历程(linux与python)
- Python在MSSQL中的应用实践(python与mssql)
- python函数缺省值与引用学习笔记分享
- python三元运算符实现方法