详解python实现可视化的MD5、sha256哈希加密小工具


Posted in Python onSeptember 14, 2020

本文主要介绍了详解python实现可视化的MD5、sha256哈希加密小工具,分享给大家,具体如下:

效果图:

刚启动的状态

详解python实现可视化的MD5、sha256哈希加密小工具

输入文本、触发加密按钮后支持复制

详解python实现可视化的MD5、sha256哈希加密小工具

超过十条不全量显示

详解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()#生成前端窗口

到此这篇关于详解python实现可视化的MD5、sha256哈希加密小工具的文章就介绍到这了,更多相关python MD5、sha256哈希加密内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
Python中文分词实现方法(安装pymmseg)
Jun 14 Python
python字符串中的单双引
Feb 16 Python
python正则表达式的使用
Jun 12 Python
Python编程把二叉树打印成多行代码
Jan 04 Python
python微信跳一跳系列之色块轮廓定位棋盘
Feb 26 Python
解决python3 网络请求路径包含中文的问题
May 10 Python
pycharm 实现显示project 选项卡的方法
Jan 17 Python
pyqt5 实现工具栏文字图片同时显示
Jun 13 Python
使用python绘制温度变化雷达图
Oct 18 Python
Django使用Profile扩展User模块方式
May 14 Python
python怎么判断模块安装完成
Jun 19 Python
pyqt5 textEdit、lineEdit操作的示例代码
Aug 12 Python
Python利用pip安装tar.gz格式的离线资源包
Sep 14 #Python
Python tkinter制作单机五子棋游戏
Sep 14 #Python
python安装cx_Oracle和wxPython的方法
Sep 14 #Python
python输入中文的实例方法
Sep 14 #Python
python与js主要区别点总结
Sep 13 #Python
python与c语言的语法有哪些不一样的
Sep 13 #Python
python的链表基础知识点
Sep 13 #Python
You might like
利用递归把多维数组转为一维数组的函数
2006/10/09 PHP
php统计文件大小,以GB、MB、KB、B输出
2011/05/29 PHP
PHP中把对象转换为关联数组代码分享
2015/04/09 PHP
用dom+xhtml+css制作的一个相册效果代码打包下载
2008/01/24 Javascript
js 提交和设置表单的值
2008/12/19 Javascript
javascript 面向对象编程基础 多态
2009/08/21 Javascript
js判断url是否有效的两种方法
2014/03/04 Javascript
JavaScript中的公有、私有、特权和静态成员用法分析
2014/11/20 Javascript
javascript实现修改微信分享的标题内容等
2014/12/11 Javascript
浅析jQuery EasyUI中的tree使用指南
2014/12/18 Javascript
javascript中innerText和innerHTML属性用法实例分析
2015/05/13 Javascript
js实现固定显示区域内自动缩放图片的方法
2015/07/18 Javascript
JavaScript仿微信打飞机游戏
2020/07/05 Javascript
详解angularjs的数组传参方式的简单实现
2017/07/28 Javascript
vue-cli 引入、配置axios的方法
2018/05/08 Javascript
axios取消请求的实践记录分享
2018/09/26 Javascript
python正则表达式抓取成语网站
2013/11/20 Python
详解Python的Django框架中的Cookie相关处理
2015/07/22 Python
python获取地震信息 微信实时推送
2019/06/18 Python
如何更优雅地写python代码
2019/07/02 Python
python异步编程 使用yield from过程解析
2019/09/25 Python
如何基于Python批量下载音乐
2019/11/11 Python
python多进程重复加载的解决方式
2019/12/13 Python
Scrapy框架基本命令与settings.py设置
2020/02/06 Python
Django权限设置及验证方式
2020/05/13 Python
纽约通行卡:The New York Pass(免费游览纽约90多个景点)
2017/07/29 全球购物
洛杉矶时尚女装系列:J.ING US
2019/03/17 全球购物
泰国Robinson百货官网:购买知名品牌的商品
2020/02/08 全球购物
英语翻译系毕业生求职信
2013/09/29 职场文书
高中英语教学反思
2014/02/04 职场文书
小学毕业感言300字
2014/02/19 职场文书
毕业生求职自荐书范文
2014/03/27 职场文书
求职信怎么写
2014/05/23 职场文书
体育口号大全
2014/06/18 职场文书
个人房屋转让协议书范本
2014/10/26 职场文书
nginx结合openssl实现https的方法
2021/07/25 Servers