这里直接把代码贴上了,还有已经把python编译成exe了,有需要可以直接下载附件。
要加什么编码转换的可以留言,可以继续改进。
import json
import base64
import urllib.parse
import binascii
import hashlib
from tkinter import *
from tkinter import ttk
from tkinter import scrolledtext
import tkinter as tk
win = tk.Tk()
win.title('编码转换工具 v1.0 By:天眼')
win.geometry("900x600+300+200")
ttk.Style().configure(".", font=("仿宋", 15))
def json1():
txt = scr1.get('0.0', 'end')
a = json.loads(txt)#这是以字符串格式转换成json
b = json.dumps(a,sort_keys=True,indent=4,separators=(',',':'),ensure_ascii=False)
scr2.insert(END,b)#输出,需要通过插入来输出
def json2():
scr1.delete('0.0','end')
scr2.delete('0.0','end')
tab = ttk.Notebook(win)
frame = tk.Frame(tab)
tb1 = tab.add(frame,text = " json格式转换 ")
scr1 = scrolledtext.ScrolledText(frame, width=95, height=17,font=(1))
scr2 = scrolledtext.ScrolledText(frame, width=95, height=17,font=(1))
scr1.place(x = 0,y = 0)
scr2.place(x = 0,y = 285)
button = Button(frame,text="转换",width=10,command = json1)#按钮
button1 = Button(frame,text="清除",width=10,command = json2)#按钮
button.place(x = 800,y = 100)
button1.place(x = 800,y = 390)
#--------------------------------------------
def b64():#编码
txt = scr3.get('0.0', 'end')
strip = txt.strip('\n')
e = base64.b64encode(strip.encode('utf-8')).decode('ascii')
scr4.insert(END,e)
def b643():#解码
txt = scr3.get('0.0', 'end')
strip = txt.strip('\n')
e = base64.b64decode(strip.encode('utf-8'))
b = e.decode()
scr4.insert(END,b)
def b32():
txt = scr3.get('0.0', 'end')
strip = txt.strip('\n')
e = base64.b32encode(strip.encode('utf-8')).decode('ascii')
scr4.insert(END,e)
def b32a():#解码
txt = scr3.get('0.0', 'end')
strip = txt.strip('\n')
e = base64.b32decode(strip.encode('utf-8'))
b = e.decode()
scr4.insert(END,b)
def b642():#清除
scr3.delete('0.0','end')
scr4.delete('0.0','end')
frame1 = tk.Frame(tab)
tab2 = tab.add(frame1,text = " base64和32编码/解码 ")
scr3 = scrolledtext.ScrolledText(frame1, width=95, height=17,font=(1))
scr4 = scrolledtext.ScrolledText(frame1, width=95, height=17,font=(1))
scr3.place(x = 0,y = 0)
scr4.place(x = 0,y = 285)
button2 = Button(frame1,text="ba64编码",width=10, command = b64)#按钮
button22 = Button(frame1,text="ba64解码",width=10, command = b643)
button20 = Button(frame1,text="ba32编码",width=10, command = b32)
button23 = Button(frame1,text="ba32解码",width=10, command = b32a)
button3 = Button(frame1,text="清除",width=10 , command = b642)#按钮
button2.place(x = 800,y = 30)
button22.place(x = 800,y = 80)#x左右,y是上下
button3.place(x = 800,y = 390)
button20.place(x = 800,y = 160)#x左右,y是上下
button23.place(x = 800,y = 210)
#--------------------------------------------------------------
def url():
txt = scr5.get('0.0','end')
strip = txt.strip('\n')
a = urllib.parse.quote(strip)
scr6.insert('0.0',a)
def url1():
txt = scr5.get('0.0', 'end')
strip = txt.strip('\n')
a = urllib.parse.unquote(strip)
scr6.insert('0.0',a)
def url2():#清除
scr5.delete('0.0','end')
scr6.delete('0.0','end')
frame2 = tk.Frame(tab)
tab3 = tab.add(frame2,text = " URL编码/解码 ")
scr5 = scrolledtext.ScrolledText(frame2, width=95, height=17,font=(1))
scr6 = scrolledtext.ScrolledText(frame2, width=95, height=17,font=(1))
scr5.place(x = 0,y = 0)
scr6.place(x = 0,y = 285)
button4 = Button(frame2,text="编码",width=10,command = url)#按钮
button44 = Button(frame2,text="解码",width=10, command = url1)
button5 = Button(frame2,text="清除",width=10,command = url2)#按钮
button4.place(x = 800,y = 50)
button44.place(x = 800,y = 150)
button5.place(x = 800,y = 390)
#------------------------------------------
def hex():
txt = scr7.get('0.0','end')
strip = txt.strip('\n')
c = strip.encode()
a =binascii.hexlify(c).decode('ascii')
scr8.insert('0.0',a)
def hex1():
b = scr7.get('0.0','end')
a = binascii.unhexlify(b.strip('\n')).decode('ascii')
scr8.insert('0.0',a)
def hex2():#清除
scr7.delete('0.0','end')
scr8.delete('0.0','end')
frame3 = tk.Frame(tab)
tab4 = tab.add(frame3,text = " 16进制编码/解码 ")
scr7 = scrolledtext.ScrolledText(frame3, width=95, height=17,font=(1))
scr8 = scrolledtext.ScrolledText(frame3, width=95, height=17,font=(1))
scr7.place(x = 0,y = 0)
scr8.place(x = 0,y = 285)
button6 = Button(frame3,text="编码",width=10,command = hex)#按钮
button66 = Button(frame3,text="解码",width=10,command = hex1)
button7 = Button(frame3,text="清除",width=10,command = hex2)#按钮
button6.place(x = 800,y = 50)
button66.place(x = 800,y = 150)
button7.place(x = 800,y = 390)
#-------------------------------------------
def md5():
txt = scr9.get('0.0','end')
b = txt.strip('\n')
a = hashlib.md5(b.encode(encoding='UTF-8')).hexdigest()
scr10.insert('0.0',a)
def md51():#清除
scr9.delete('0.0','end')
scr10.delete('0.0','end')
frame4 = tk.Frame(tab)
tab5 = tab.add(frame4,text = " MD5加密 ")
scr9 = scrolledtext.ScrolledText(frame4, width=95, height=17,font=(1))
scr10 = scrolledtext.ScrolledText(frame4, width=95, height=17,font=(1))
scr9.place(x = 0,y = 0)
scr10.place(x = 0,y = 285)
button8 = Button(frame4,text="加密",width=10,command = md5)#按钮
button9 = Button(frame4,text="清除",width=10,command = md51)#按钮
button8.place(x = 800,y = 50)
button9.place(x = 800,y = 390)
tab.pack(expand = True, fill = 'both')
win.mainloop()
用户名 | 金币 | 积分 | 时间 | 理由 |
---|---|---|---|---|
奖励系统 | 50.00 | 0 | 2020-12-07 20:08:44 | 投稿满 5 赞奖励 |
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
欧阳春
发表于 2020-12-30
膜拜大佬
评论列表
加载数据中...
李万吉
发表于 2020-11-29
1
评论列表
加载数据中...
ajming
发表于 2020-11-29
dddd,框架那一块就不会写
评论列表
加载数据中...
test123
发表于 2020-11-30
666
评论列表
加载数据中...
麻辣小龙瞎扯淡
发表于 2020-11-30
1
评论列表
加载数据中...
luck1213
发表于 2020-12-1
杂项里面经常遇到各种加密,膜拜大佬!
评论列表
加载数据中...
tianmao
发表于 2020-12-2
666
评论列表
加载数据中...
west_black
发表于 2020-12-3
1
评论列表
加载数据中...
z120z960z2663
发表于 2020-12-8
膜拜巨佬。
评论列表
加载数据中...
ypwypw1994
发表于 2020-12-11
666
评论列表
加载数据中...
hadesi
发表于 2020-12-24
666
评论列表
加载数据中...
darren
发表于 2020-12-31
666
评论列表
加载数据中...
柠檬
发表于 2021-2-19
666
评论列表
加载数据中...
merlinzhs
发表于 2021-5-31
1
评论列表
加载数据中...
lbclbclbc
发表于 2021-6-17
1
评论列表
加载数据中...
常长老
发表于 2021-7-11
1
评论列表
加载数据中...
清河逸尘
发表于 2021-8-22
1
评论列表
加载数据中...
和谐文明
发表于 2021-11-19
1
评论列表
加载数据中...
ruif777
发表于 2022-3-2
谢谢大佬
评论列表
加载数据中...
zjl
发表于 2022-12-27
66
评论列表
加载数据中...