猫史档案馆


【Python作品分享】加密器【作品秀】

用户:sky-*^O^*sky-*^O^*查看:1 回复:3 评论:1 创建时间:2021-12-31T19:52:26


【作品展示】

center_image

 

【作品介绍】

加/解密器:

可以进行简单加密/解密

还是不错的

 

【作品源代码】

import tkinter as tk
from tkinter import filedialog
import base喵 as ba
def find():
	a=filedialog.askopenfilename()
	entry.delete(0,'end')
	entry.insert(0,a)

def jia():
	try:
		with open(entry.get(),mode='rb') as f:
			r=f.read()
			name=entry.get()
			_=name.split('/')
			l_name=_[len(_)-1]
			f_name=_[:len(name)-len(l_name)]
			_=l_name.split('.')
			s_name=_[len(_)-1]
	except:
		a=tk.Tk()
		a.title('发生错误,请确认')
		a.resizable(False,False)
		tk.Label(a,text='找不到文件,请确认',font=(None,25)).pack()
		return
	with open(l_name[:len(s_name)]+'加密'+'.'+s_name,mode='wb') as f:
		wr=ba.b喵encode(r)
		f.write(wr)
	a=tk.Tk()
	tk.Label(a,text='加密成功',font=(None,25)).pack()

def jie():
	try:
		with open(entry.get(),mode='rb') as f:
			r=f.read()
			name=entry.get()
			_=name.split('/')
			l_name=_[len(_)-1]
			f_name=_[:len(name)-len(l_name)]
			_=l_name.split('.')
			s_name=_[len(_)-1]
	except:
		a=tk.Tk()
		a.title('发生错误,请确认')
		a.resizable(False,False)
		tk.Label(a,text='找不到文件,请确认',font=(None,25)).pack()
		return
	with open(l_name[:len(s_name)]+'解密'+'.'+s_name,mode='wb') as f:
		wr=ba.b喵decode(r)
		f.write(wr)
	a=tk.Tk()
	tk.Label(a,text='解密成功',font=(None,25)).pack()

root=tk.Tk()
root.title('加/解密器')
root.geometry('550x260')
root.resizable(False,False)

title=tk.Frame(root,bg='#fff8dc')
tk.Label(title,text='加/解密器',font=('simhei',40),
	bg='#fff8dc').place(x=125,y=20,height=50,width=300)
title.place(width=550,height=70)

win=tk.Frame(root,bg='#fff8dc')
win.place(width=550,height=95,y=70)
entry=tk.Entry(win,font=('simhei',15))
entry.place(x=30,y=25,height=40,width=403)
tk.Button(win,text='浏览',command=find,
	font=('simhei',15)).place(x=460,y=25,width=60,height=40)

do=tk.Frame(root,bg='#fff8dc')
do.place(y=165,width=550,height=95)
tk.Button(do,command=jia,text='加密',
	font=('simhei',15)).place(x=90,y=30,height=50,width=70)
tk.Button(do,command=jie,text='解密',
	font=('simhei',15)).place(x=390,y=30,height=50,width=70)

tk.mainloop()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
Vincent_xiaoboVincent_xiaobo

报错了center_image

点赞0


评论


伴雪纷飞伴雪纷飞

base64是为了告诉别人我加密了

点赞0


评论


EUWEUW

不如我的 https://shequ.codemao.cn/community/1626931

点赞0


评论