python-md5加密

python实现:md5_hash.py

#-*- coding: UTF-8 -*-

__author__ = ''
__date__ = '2016/4/11' from Tkinter import *
import hashlib class md5_hash():
md5_char = ""
def __init__(self):
self.root = Tk()
self.root.title("md5加密")
self.root.geometry() #top
Label(self.root, text="md5加密", bg="magenta", font=("Arial",15)).pack()
self.frm = Frame(self.root) self.frm_T = Frame(self.frm)
self.var_char = StringVar()
Label(self.frm_T, text="请输入", bg="cyan", font=("Arial",12)).pack(side=LEFT)
Entry(self.frm_T,textvariable=self.var_char, font=("Arial",15),width=27).pack(side=RIGHT)
self.frm_T.pack() #bottom
self.frm_B = Frame(self.frm)
#Label(self.frm_B, text="md5加密结果",bg="cyan", font=("Arial",12)).pack(side=LEFT)
self.md5_show = Text(self.frm_B, height=2, font=("Arial",15),width=32)
self.md5_show.insert("1.0","")
self.md5_show.pack(anchor=W)
self.frm_BM = Frame(self.frm_B)
Button(self.frm_BM,text="清除", command=self.clear, width=6, height=1, bd=3, font=("Arial",10)).pack(side=LEFT)
Button(self.frm_BM,text="md5加密", command=self.md5_en, width=6, height=1, bd=3, font=("Arial",10)).pack(side=RIGHT)
self.frm_BM.pack(side=BOTTOM)
self.frm_B.pack() self.frm.pack() def clear(self):
self.var_char.set("")
self.md5_show.delete("1.0","2.0") def md5_en(self): self.md5_show.delete("1.0","2.0")
tmp_char = self.var_char.get()
if tmp_char != '':
self.md5_char = hashlib.md5()
self.md5_char.update(tmp_char)
self.md5_show.insert("1.0",self.md5_char.hexdigest())
else:
return "" def main():
m = md5_hash()
mainloop() if __name__ == "__main__":
main()

运行结果:

python-md5加密

exe文件下载:(提取码:b4e4)

上一篇:Vue中的computed 解读


下一篇:centos 7.0 编译安装php 7.0.3