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

2021-09-14 02:31:39 字數 4047 閱讀 9539

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)

defclear()

: 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=

'清空所有'

'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)

defclear()

: 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=

'清空所有'

base64 的加密和解密

coding utf 8 如果報non ascii character xe6 in file odoo 123.py on line 5,but no encoding declared類似的這個錯加入這行就解決了 import base64 加密 defencryption str 想將字串轉編...

python中base64加密和解密

base64加密和解密有點頭疼,必須要記錄下來,以後忘了也能再來複習下 當然啦,能一直記住是最好的 加油吧,少年 其實已經好老了 win10,python3 這個還是別人講的好,詳情請看 base64編碼原理與應用 其實它的原理不是很難,以下是幾個小案例 import base64 str admi...

Base64加密解密

public class base64 對應asicc字元的位置 public static string base64encode string str c2 str i if i len c3 str i out base64encodechars c1 2 out base64encodech...