1. 程式人生 > >python 自定義加密與解密

python 自定義加密與解密

import tkinter
import webbrowser
import re

#本程式是一箇中文字元和中文檢測工具
#中文字元自己新增,我只添加了一點
#輸入字串,點選檢查文字即可判斷有沒有中文字元
# qianxiao996精心製作
#部落格地址:https://blog.csdn.net/qq_36374896

win = tkinter.Tk()
win.title("中文字元檢測工具   "+"by qianxiao996"+"    -----部落格地址:https://blog.csdn.net/qq_36374896  QQ:1919010193-----")

#獲取全部內容
def showInfo():
    returntext.delete(0.0, tkinter.END)   #清空returntext中的內容
    str=text.get(0.0, tkinter.END)    #得到text中的文字
    list=[',','。',':','¥',';','“','‘']  #中文字元可以自行新增
    endstr=""  #存放文字中的特殊字元
    zhPattern = re.compile(u'[\u4e00-\u9fa5]+') #匹配中文的正則表示式
    for i in str:   #遍歷整個文字是否含有中文字元
        if i in list:   #遍歷是否含有list中的字元
            endstr+=i
        elif zhPattern.search(i):   #遍歷是否是漢字
            endstr += i
    if endstr !='':   #輸出中文字元
        returntext.insert(tkinter.INSERT, "中文字元:"+endstr)
    else:
        returntext.insert(tkinter.INSERT, "恭喜您,文字中沒有中文字元")
#清空
def clearText():
    text.delete(0.0, tkinter.END)
    returntext.delete(0.0, tkinter.END)
def click():
    webbrowser.open("https://blog.csdn.net/qq_36374896")

#建立滾動條
scroll = tkinter.Scrollbar()
#height:顯示的行數
str = "請在此輸入您的文字(請刪除此字串):"
text = tkinter.Text(win,width =80,height = 50,bg='#F0FFFF',fg="#FF00FF")

text.insert(tkinter.INSERT,str)
#side 放到窗體的哪一側
scroll.pack(side  =tkinter.RIGHT,fill = tkinter.Y)
text.pack(side  =tkinter.LEFT,fill = tkinter.Y,)
#關聯
scroll.config(command =text.yview)
text.config(yscrollcommand =scroll.set)
label = tkinter.Label(win,text= "作者QQ:1919010193",bg='#F0F8FF',fg="green").pack(side="bottom",ipady="8",ipadx="44")
zuozhe=tkinter.Button(win,text= "作者主頁",command =click,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
close = tkinter.Button(win,text= "關閉程式",command =win.quit,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
clear = tkinter.Button(win,text= "清空文字",command = clearText,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
button = tkinter.Button(win,text= "檢查文字",command = showInfo,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
returntext = tkinter.Text(win,width = 30,height=30,bg='#F0FFFF',foreground='red')
returntext.pack(side="top",ipadx="3")
win.mainloop()