BASE64的加密和解密工具(GUI)

import tkinter as tk
from tkinter import *
import base64

window=tk.Tk()
window.title('base64生成解密程序')
window.geometry('800x600')
labeltext="请在下面输入要加密的字符串\n注意:换行符、头尾空格会被自动去除!"
textLabel = Label(window, text=labeltext, bg = 'red',fg = 'black' , justify=LEFT)
textLabel.pack(side=TOP)
t0=tk.Text(window,height=20)
t0.pack()
def make():
    var=t0.get("0.0", "end")
    res=""
    allres=""
    for i in var:  
        res = res + i
        if (i == '\n'):
            allres = allres + res.strip().replace("\n", "")
            res=""

    t.config(state=NORMAL)
    t.delete("0.0", "end")
    t.insert('insert',"生成的密码:["  + bytes.decode(base64.b64encode(bytes(allres, encoding="utf8"))) + "]")
    t.config(state=DISABLED)
    t3.config(state=NORMAL)
    t3.delete("0.0", "end")
    t3.insert('insert', "格式化后的字符串:["+allres +"]")
    t3.config(state=DISABLED)

def clear():
    var = t0.get("0.0", "end")
    t0.delete("0.0", "end")

    t.config(state=NORMAL)
    t.delete("0.0", "end")
    t.config(state=DISABLED)
    t3.config(state=NORMAL)
    t3.delete("0.0", "end")
    t3.config(state=DISABLED)

t3=tk.Text(window,height=10,bg="#AD58E6")     #这里设置文本框高,可以容纳两行
t3.pack(side = TOP)

t=tk.Text(window,height=10,bg="#ADD8E6")     #这里设置文本框高,可以容纳两行
t.pack(side = TOP)


frame1 = Frame(window)
frame1.pack(side = TOP)
b1=tk.Button(frame1,text='生成密码',width=10,height=2,command=make)
b1.pack(side=RIGHT)
b2=tk.Button(frame1,text='清空所有',width=10,height=2,command=clear)
b2.pack(side=LEFT)
window.mainloop()

在这里插入图片描述

import tkinter as tk
from tkinter import *
import base64

window=tk.Tk()
window.title('base64生成解密程序')
window.geometry('800x600')
labeltext="请在下面输入要解密的字符串\n注意:换行符、头尾空格会被自动去除!"
textLabel = Label(window, text=labeltext, bg = 'red',fg = 'black' , justify=LEFT)
textLabel.pack(side=TOP)
t0=tk.Text(window,height=20)
t0.pack()
def make():
    var=t0.get("0.0", "end")
    res = ""
    allres = ""
    for i in var: 
        res = res + i
        if (i == '\n'):
            allres = allres + res.strip().replace("\n", "")
            res = ""
    t.config(state=NORMAL)
    t.delete("0.0", "end")
    t.insert('insert',"解密后的字符串:["  + bytes.decode(base64.b64decode(bytes(allres, encoding="utf8"))) + "]")
    t.config(state=DISABLED)

def clear():
    var = t0.get("0.0", "end")
    t0.delete("0.0", "end")

    t.config(state=NORMAL)
    t.delete("0.0", "end")
    t.config(state=DISABLED)


t=tk.Text(window,height=10,bg="#ADD8E6")     #这里设置文本框高,可以容纳两行
t.pack(side = TOP)


frame1 = Frame(window)
frame1.pack(side = TOP)
b1=tk.Button(frame1,text='解密',width=10,height=2,command=make)
b1.pack(side=RIGHT)
b2=tk.Button(frame1,text='清空所有',width=10,height=2,command=clear)
b2.pack(side=LEFT)
window.mainloop()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值