詳解python實(shí)現(xiàn)可視化的MD5、sha256哈希加密小工具
本文主要介紹了詳解python實(shí)現(xiàn)可視化的MD5、sha256哈希加密小工具,分享給大家,具體如下:
效果圖:
剛啟動(dòng)的狀態(tài)
輸入文本、觸發(fā)加密按鈕后支持復(fù)制
超過(guò)十條不全量顯示
代碼
import hashlibimport tkinter as tk#窗口控制windowss=tk.Tk()windowss.title(’Python_md5’)#窗口title,并非第一行windowss.geometry(’820x550’)windowss.resizable(width=True, height=True)#寬度可變,高度可變#label組件-文本標(biāo)簽label1=tk.Label(windowss,text='請(qǐng)輸入文本').grid(row=0, column=0)#生成labellabel2=tk.Label(windowss,text='MD5:').grid(row=3, column=0)#生成結(jié)果固定labellabel3=tk.Label(windowss,text='SHA256:').grid(row=4, column=0)#生成結(jié)果固定label#entry組件-文本輸入框E12=tk.Text(windowss,width=80,bd=2.5,height=10,relief='sunken')E12.grid(row=0,column=1)#輸入正則表達(dá)式入口#進(jìn)入解析模式j(luò)udge_text1 = tk.StringVar()judge_text1.set('暫未輸入')judge_text2 = tk.StringVar()judge_text2.set('')def copy(text2): windowss.clipboard_clear() # 清除剪貼板內(nèi)容 windowss.clipboard_append(text2)def judge(): text1 = E12.get(’0.0’,’end’)#’0.0’,’end’全量讀取 to_one_line = ’ ’.join(text1.split())#轉(zhuǎn)化為列表1 test_list = to_one_line.split(’ ’)#轉(zhuǎn)化為列表2 m1='' m2='' for texts in test_list: matcher_md5_new= hashlib.md5(texts.encode(’utf8’))#md5轉(zhuǎn)化 matcher_md5 = str(matcher_md5_new.hexdigest())#獲取md5 m1=m1+'n'+matcher_md5#分行 matcher_sha256_new = hashlib.sha3_256(texts.encode(’utf8’))#轉(zhuǎn)化為sha256 matcher_sha256 = str(matcher_sha256_new.hexdigest()) m2 = m2 + 'n' + matcher_sha256 if len(test_list)>10:#大于十條數(shù)據(jù)時(shí),不完全顯示 T3 = tk.Label(windowss,text='').grid(row=5, column=1) T4 = tk.Label(windowss,text='tips:最大顯示10條解析文本,可全量復(fù)制!').grid(row=6, column=1) judge_text1.set(m1) judge_text2.set(m2) #生成復(fù)制按鈕,用了lambda可以排除按鈕之間干擾 B2 = tk.Button(windowss, text='復(fù)制md5', width=10, height=2, command=lambda:copy(str(m1))).grid(row=1, column=0) B3 = tk.Button(windowss, text='復(fù)制sha256', width=10, height=2, command=lambda:copy(str(m2))).grid(row=1, column=2)#設(shè)置加密按鈕,command表示觸發(fā)條件B1=tk.Button(windowss,text='哈希加密',width=10,height=2,command=judge).grid(row=1,column=1)#輸出結(jié)果T1 = tk.Label(windowss, width=70, height=10,bd=0,textvariable=judge_text1).grid(row=3, column=1) # 生成結(jié)果 md5T2 = tk.Label(windowss, width=70,height=10, bd=0,textvariable=judge_text2).grid(row=4, column=1) # 生成結(jié)果 sha256windowss.mainloop()#生成前端窗口
到此這篇關(guān)于詳解python實(shí)現(xiàn)可視化的MD5、sha256哈希加密小工具的文章就介紹到這了,更多相關(guān)python MD5、sha256哈希加密內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. python 如何在 Matplotlib 中繪制垂直線2. ASP常用日期格式化函數(shù) FormatDate()3. 開(kāi)發(fā)效率翻倍的Web API使用技巧4. 如何通過(guò)python實(shí)現(xiàn)IOU計(jì)算代碼實(shí)例5. bootstrap select2 動(dòng)態(tài)從后臺(tái)Ajax動(dòng)態(tài)獲取數(shù)據(jù)的代碼6. CSS3中Transition屬性詳解以及示例分享7. js select支持手動(dòng)輸入功能實(shí)現(xiàn)代碼8. Python 操作 MySQL數(shù)據(jù)庫(kù)9. vue使用moment如何將時(shí)間戳轉(zhuǎn)為標(biāo)準(zhǔn)日期時(shí)間格式10. python中@contextmanager實(shí)例用法
