import hashlib
import hmac
import tkinter as tk
def md5():
text = input_text.get()
obj = hashlib.md5('c4ca4238a0b923820dcc509a6f75849b'.encode("utf-8")) # 添加一些内容,提高加密复杂度。
obj.update(text.encode("utf-8"))
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, obj.hexdigest())
def hmacmod():
text = input_text.get()
h = hmac.new('c4ca4238a0b923820dcc509a6f75849b'.encode("utf-8")) #不同的盐值加密结果不相同
h.update(text.encode("utf-8"))
output_text.delete(1.0, tk.END)
output_text.insert(tk.END, h.hexdigest())
# 创建GUI窗口
window = tk.Tk()
window.title("字符串转换MD5小工具")
window.geometry("500x300+100+200")
# 创建输入框
input_label = tk.Label(window, text="输入需要加密的字符串:")
input_label.pack()
input_text = tk.Entry(window)
input_text.pack()
# 创建转换按钮
convert_button = tk.Button(window, text="使用MD5加密", command=md5)
convert_button.pack()
convert_button = tk.Button(window, text="使用加盐MD5加密", command=hmacmod)
convert_button.pack()
# 创建输出框
output_label = tk.Label(window, text="MD5值:")
output_label.pack()
output_text = tk.Text(window, height=5, width=30)
output_text.pack()
window.mainloop()
示例图片:
GUI程序
链接:https://pan.baidu.com/s/1psq9kkaiKL8C1PU8KG-o2g
提取码:yomi |