详解python实现可视化的MD5、sha256哈希加密小工具
作者:Gg_ning 时间:2021-05-31 15:02:34
本文主要介绍了详解python实现可视化的MD5、sha256哈希加密小工具,分享给大家,具体如下:
效果图:
刚启动的状态
输入文本、触发加密按钮后支持复制
超过十条不全量显示
代码
import hashlib
import tkinter as tk
#窗口控制
windowss=tk.Tk()
windowss.title('Python_md5')#窗口title,并非第一行
windowss.geometry('820x550')
windowss.resizable(width=True, height=True)#宽度可变,高度可变
#label组件-文本标签
label1=tk.Label(windowss,text="请输入文本").grid(row=0, column=0)#生成label
label2=tk.Label(windowss,text="MD5:").grid(row=3, column=0)#生成结果固定label
label3=tk.Label(windowss,text="SHA256:").grid(row=4, column=0)#生成结果固定label
#entry组件-文本输入框
E12=tk.Text(windowss,width=80,bd=2.5,height=10,relief="sunken")
E12.grid(row=0,column=1)#输入正则表达式入口
#进入解析模式
judge_text1 = tk.StringVar()
judge_text1.set("暂未输入")
judge_text2 = tk.StringVar()
judge_text2.set("")
def copy(text2):
windowss.clipboard_clear() # 清除剪贴板内容
windowss.clipboard_append(text2)
def judge():
text1 = E12.get('0.0','end')#'0.0','end'全量读取
to_one_line = ' '.join(text1.split())#转化为列表1
test_list = to_one_line.split(' ')#转化为列表2
m1=""
m2=""
for texts in test_list:
matcher_md5_new= hashlib.md5(texts.encode('utf8'))#md5转化
matcher_md5 = str(matcher_md5_new.hexdigest())#获取md5
m1=m1+"\n"+matcher_md5#分行
matcher_sha256_new = hashlib.sha3_256(texts.encode('utf8'))#转化为sha256
matcher_sha256 = str(matcher_sha256_new.hexdigest())
m2 = m2 + "\n" + matcher_sha256
if len(test_list)>10:#大于十条数据时,不完全显示
T3 = tk.Label(windowss,text="").grid(row=5, column=1)
T4 = tk.Label(windowss,text="tips:最大显示10条解析文本,可全量复制!").grid(row=6, column=1)
judge_text1.set(m1)
judge_text2.set(m2)
#生成复制按钮,用了lambda可以排除按钮之间干扰
B2 = tk.Button(windowss, text="复制md5", width=10, height=2, command=lambda:copy(str(m1))).grid(row=1, column=0)
B3 = tk.Button(windowss, text="复制sha256", width=10, height=2, command=lambda:copy(str(m2))).grid(row=1, column=2)
#设置加密按钮,command表示触发条件
B1=tk.Button(windowss,text="哈希加密",width=10,height=2,command=judge).grid(row=1,column=1)
#输出结果
T1 = tk.Label(windowss, width=70, height=10,bd=0,textvariable=judge_text1).grid(row=3, column=1) # 生成结果 md5
T2 = tk.Label(windowss, width=70,height=10, bd=0,textvariable=judge_text2).grid(row=4, column=1) # 生成结果 sha256
windowss.mainloop()#生成前端窗口
来源:https://blog.csdn.net/Gg_ning/article/details/108537289
标签:python,MD5,sha256,哈希加密
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现贪吃蛇小游戏(双人模式)
2021-06-07 11:15:02
python使用matplotlib:subplot绘制多个子图的示例
2021-01-26 18:13:08
![](https://img.aspxhome.com/file/2023/6/67816_0s.png)
基于PHP常用文件函数和目录函数整理
2023-06-09 22:02:34
从源码解析Python的Flask框架中request对象的用法
2021-02-20 02:15:57
该用多大的字
2009-05-17 14:39:00
详解如何使用Pytorch进行多卡训练
2023-08-02 06:43:29
python基于gevent实现并发下载器代码实例
2024-01-01 00:31:53
python实现猜拳游戏
2023-09-15 00:24:04
![](https://img.aspxhome.com/file/2023/2/117842_0s.jpg)
如何解决从文本文件中调出记录出现丢失换行的问题?
2009-12-03 20:25:00
matplotlib绘制鼠标的十字光标的实现(自定义方式,官方实例)
2021-06-09 02:33:06
使用python实现对元素的长截图功能
2023-11-20 10:27:44
![](https://img.aspxhome.com/file/2023/3/63923_0s.png)
如何使用Django Admin管理后台导入CSV
2022-12-28 19:56:52
![](https://img.aspxhome.com/file/2023/5/69635_0s.png)
Python开发之基于模板匹配的信用卡数字识别功能
2021-08-09 22:30:27
![](https://img.aspxhome.com/file/2023/3/120273_0s.png)
Python catplot函数自定义颜色的方法
2021-01-29 16:25:01
![](https://img.aspxhome.com/file/2023/1/95491_0s.png)
opencv-python图像增强解读
2022-10-10 04:29:16
详解Python 字符串相似性的几种度量方法
2023-06-19 14:12:39
Python使用enumerate获取迭代元素下标
2023-03-05 01:46:31
python+django快速实现文件上传
2021-03-12 19:07:38
![](https://img.aspxhome.com/file/2023/5/85015_0s.png)
扫盲大讲堂:mysql出错的代码解析及解答
2009-09-05 10:08:00
python通过定义一个类实例作为ftp回调方法
2021-08-16 14:12:03