详解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 dict remove数组删除(del,pop)
Mar 24 Python
Python中使用支持向量机SVM实践
Dec 27 Python
Java实现的执行python脚本工具类示例【使用jython.jar】
Mar 29 Python
浅谈Python批处理文件夹中的txt文件
Mar 11 Python
Python Matplotlib实现三维数据的散点图绘制
Mar 19 Python
python中正则表达式与模式匹配
May 07 Python
Python中使用双下划线防止类属性被覆盖问题
Jun 27 Python
python sorted方法和列表使用解析
Nov 18 Python
浅谈python累加求和+奇偶数求和_break_continue
Feb 25 Python
Pytorch mask-rcnn 实现细节分享
Jun 24 Python
Django中Aggregation聚合的基本使用方法
Jul 09 Python
Python中22个万用公式的小结
Jul 21 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
用PHP查询域名状态whois的类
2006/11/25 PHP
比较好用的PHP防注入漏洞过滤函数代码
2012/04/11 PHP
php中FTP函数ftp_connect、ftp_login与ftp_chmod用法
2014/11/18 PHP
PHP生成指定随机字符串的简单实现方法
2015/04/01 PHP
CL vs ForZe BO5 第四场 2.13
2021/03/10 DOTA
分享15个大家都熟知的jquery小技巧
2015/12/02 Javascript
解决JavaScript数字精度丢失问题的方法
2015/12/03 Javascript
从零学习node.js之搭建http服务器(二)
2017/02/21 Javascript
javaScript canvas实现(画笔大小 颜色 橡皮的实例)
2017/11/28 Javascript
Vue cli 引入第三方JS和CSS的常用方法分享
2018/01/20 Javascript
JavaScript中发出HTTP请求最常用的方法
2018/07/12 Javascript
解决ant-design-vue中menu菜单无法默认展开的问题
2020/10/31 Javascript
[08:40]Navi Vs Newbee
2018/06/07 DOTA
Python中的面向对象编程详解(上)
2015/04/13 Python
python实现批量改文件名称的方法
2015/05/25 Python
wxPython的安装与使用教程
2018/08/31 Python
python单例模式的多种实现方法
2019/07/26 Python
python GUI库图形界面开发之PyQt5信号与槽基本操作
2020/02/25 Python
python保留格式汇总各部门excel内容的实现思路
2020/06/01 Python
OpenCV 使用imread()函数读取图片的六种正确姿势
2020/07/09 Python
安装并免费使用Pycharm专业版(学生/教师)
2020/09/24 Python
python 读取、写入txt文件的示例
2020/09/27 Python
基于Python爬取搜狐证券股票过程解析
2020/11/18 Python
Hotels.com中国区:好订网
2016/08/18 全球购物
Sneaker Studio罗马尼亚网站:购买运动鞋
2018/11/04 全球购物
HttpServlet类中的主要方法都有哪些?各自的作用是什么?
2014/03/16 面试题
教师的实习鉴定
2013/12/15 职场文书
消防安全管理制度
2014/02/01 职场文书
《可爱的动物》教学反思
2014/02/22 职场文书
卫生巾广告词
2014/03/18 职场文书
《狼和小羊》教学反思
2014/04/20 职场文书
文化建设工作方案
2014/05/12 职场文书
前台岗位职责
2015/02/13 职场文书
培训讲师开场白
2015/06/01 职场文书
工伤事故赔偿协议书
2015/08/06 职场文书
预备党员的思想汇报,你真的会写吗?
2019/06/28 职场文书