import tkinter as tk
upper_password = {
'A':('△','▽','○'),'B':('◇','□','☆'),'C':('▷','◁','♤'),'D':('♡','♢','♧'),'E':('▲','▼','●'),'F':('◆','■','★'),'G':('▶','◀','♠'),
'H':('☼','☽','♀'),'I':('☺','◐','☑'),'J':('√','✔','☜'),'K':('☝','☞','㏂'),'L':('☀','☾','♂'),'M':('☹','◑','☒'),'N':('×','✘','☚'),
'O':('☟','☛','㏘'),'P':('ā','ē','ū'),'Q':('ㄚ','ㄈ','ㄣ'),'R':('▪','•','‥'),'S':('…','▁','▂'),'T':('▃','▄','▅'),
'U':('▆','▇','█'),'V':('∷','※','░'),'W':('▒','▓','▏'),'X':('▎','▍','▌'),'Y':('▋','▊','▉'),'Z':('♩','♪','♫'),
'1':('1','1','1'),'2':('2','2','2'),'3':('3','3','3'),'4':('4','4','4'),'5':('5','5','5'),'6':('6','6','6'),'7':('7','7','7'),'8':('8','8','8'),'9':('9','9','9'),
}
lower_password = {'a':('┌','┬','┐'),'b':('├','┼','┤'),'c':('└','┴','┘'),'d':('┏','┳','┓'),'e':('┣','╋','┫'),'f':('┗','┻','┛'),'g':('╔','╦','╗'),
'h':('╠','╬','╣'),'i':('╚','╩','╝'),'j':('╭','─','╮'),'k':('│','╳','┃'),'l':('╰','━','╯'),'m':('α','β','γ'),'n':('δ','ε','ζ'),
'o':('η','θ','ι'),'p':('ǜ','ň','ì'),'q':('ó','ㄨ','ê'),'r':('κ','λ','μ'),'s':('ν','ξ','ο'),'t':('Δ','ρ','σ'),
'u':('τ','υ','φ'),'v':('χ','ψ','ω'),'w':('∵','∴','∷'),'x':('㏒','㏑','∑'),'y':('∏','∅','∝'),'z':('∞','∽','∉'),
'`':('`','`','`'),'~':('~','~','~'),'!':('!','!','!'),'@':('@','@','@'),'#':('#','#','#'),'$':('$','$','$'),'%':('%','%','%'),
'^':('^','^','^'),'&':('&','&','&'),'*':('*','*','*'),'(':('(','(','('),')':(')',')',')'), '-':('-','-','-'),'_':('_','_','_'),
'=':('=','`=','='),'+':('+','+','+'),'{':('{','{','{'),'}':('}','}','}'),'[':('[','[','['),']':(']',']',']'),'|':('|','|','|'),
'\\':('\\','\\','\\'),':':(':',':',':'),';':(';',';',';'),'\"':('\"','\"','\"'),'\'':('\'','\'','\''),'<':('<','<','<'),'>':('>','>','>'),
',':(',',',',','),'.':('.','.','.'),'?':('?','?','?'),'/':('/','/','/'),
}
def algor1(string):
import random
upw = upper_password
lpw = lower_password
newstring = ''
for letter in string:
if letter in upw:
newletter = random.choice(upw[letter])
newstring = newstring+newletter
elif letter in lpw:
newletter = random.choice(lpw[letter])
newstring = newstring+newletter
else:
newstring = newstring+letter
return newstring
def algor2(string):
upw2 = upper_password
lpw2 = lower_password
upw_ = {value:key for key,value in upw2.items()}
lpw_ = {value:key for key,value in lpw2.items()}
newstring = ''
newstringl = []
for letter in string:
x = 0
y = True
if letter == ' ':
newstring = newstring+letter
elif letter == '\n':
newstring =newstring+'\n'
elif letter == '\t':
newstring = newstring+'\t'
for pw in upw_:
if letter in pw:
x = x+1
y = True
newstring = newstring+upw_[pw]
else:
y = False
for pw in lpw_:
if letter in pw:
if y == True:
pass
elif y == False:
if letter in pw:
x = x+1
y = True
newstring = newstring+lpw_[pw]
else:
y = False
else:
y = False
if x == 0 :
newstringl.append(letter)
elif x != 0:
pass
nsl = newstringl
def dp(alist):
thelist = []
for i in alist:
if i not in thelist:
thelist.append(i)
return thelist
nsl = dp(nsl)
for i in nsl:
newstring = newstring+i
return newstring
root = tk.Tk()
root.title('恩格尼码主程序')
root.geometry('1200x600')
label1 = tk.Label(root,text='点击上方菜单即可进行恩格尼码的加密与解密。\n点击下方按钮即可查看说明书。',font=('楷体','18'))
label1.pack()
def allfg():
label1.pack_forget()
label2.pack_forget()
label3.pack_forget()
button1.pack_forget()
button2.pack_forget()
button3.pack_forget()
button4.pack_forget()
button5.pack_forget()
button6.pack_forget()
button7.pack_forget()
try:
text1.pack_forget()
except:
pass
text2.pack_forget()
text3.pack_forget()
text4.pack_forget()
text5.pack_forget()
def rhp():
allfg()
label1.pack()
button1.pack()
button2.pack()
button3.pack()
try:
text1.pack()
except:
pass
def encry():
allfg()
text2.pack()
label2.pack()
text3.pack()
button4.pack()
button5.pack()
def decry():
allfg()
text4.pack()
label3.pack()
text5.pack()
button6.pack()
button7.pack()
_menu = tk.Menu(root)
menu1 = _menu.add_command(label='主页',command=rhp)
menu2 = _menu.add_command(label='加密',command=encry)
menu3 = _menu.add_command(label='解密',command=decry)
root.config(menu=_menu)
def view():
global text1
text1 = tk.Text(root,width=600,height=300,font=('楷体','18'))
text1.pack()
text1.insert(tk.END,'''恩格尼码使用说明书
JJO Python应用程序有限公司2024年7月5日星期五0时0分0秒版
2024年7月5日诞生的JJO恩格尼码密码编译程序是一款十分好用的密码编译工具,其使用如下:
1.加密时,必须采用英文(字母或符号必须为英文模式下的字符),否则无效。解密时,若加密方的字母为英文输入法的英文字母、英文符号,将会翻译为英文字母和符号,否则可能无效。
2.无论是加密还是解密,原文本尽量少出现特殊字符,比如“∑”符号,最多只能出现一次。若要多次出现,可以让文本采取如下方式:
注:该文本只用“sum”代替“∑”符号。
求和符号“sum”是用来方便表示连续整数之和的。“sum”运算符是一个大型运算符。
3.该软件仅适用于聊天或娱乐领域,使用时不建议超出领域范围。
4.大多数符号必须为英文。附:非全部。
Over.''')
def des():
text1.pack_forget()
def a():
text3.delete('1.0','end')
text3.insert(tk.END,algor1(text2.get('1.0','end-1c')))
def b():
text2.delete('1.0','end')
def c():
text5.delete('1.0','end')
text5.insert(tk.END,algor2(text4.get('1.0','end-1c')))
def d():
text4.delete('1.0','end')
button1 = tk.Button(root,text='查看说明书',command=view)
button1.pack()
button2 = tk.Button(root,text='关闭说明书',command=des)
button2.pack()
button3 = tk.Button(root,text='关闭',command=root.destroy)
button3.pack()
text2 = tk.Text(root,font=('宋体','15'),width=600,height=10)
label2 = tk.Label(root,font=('楷体','18'),text="在上面的输入框输入要加密的内容,按下最下面的按钮,就能将加密内容显示在下面的输入框中。")
text3 = tk.Text(root,font=('宋体','15'),width=600,height=10)
button4 = tk.Button(root,text="开始加密",font=('隶书','18'),command=a)
button5 = tk.Button(root,text="清空输入框",font=('隶书','18'),command=b)
text4 = tk.Text(root,font=('宋体','15'),width=600,height=10)
label3 = tk.Label(root,font=('楷体','18'),text="在上面的输入框输入要解密的内容,按下最下面的按钮,就能将解密内容显示在下面的输入框中。")
text5 = tk.Text(root,font=('宋体','15'),width=600,height=10)
button6 = tk.Button(root,font=('隶书','18'),text="开始解密",command=c)
button7 = tk.Button(root,font=('隶书','18'),text='清空输入框',command=d)
root.mainloop()
以上就是代码。(一共187行)
那么这个程序又有啥用呢?
1.这个程序可以加密、解密密码,且外人破解大概有些难度,因为密码的加密是由随机特殊字符加密的。但该程序的解密器可以破译。
2.余见说明书(打开程序后可以查看。)
标签:加密,forget,Python,newstring,自制,tk,letter,root,pack From: https://blog.csdn.net/weixin_49095350/article/details/140203854