7
ลง
4
เก็บรวบรวม
รายงาน
แบ่งปัน

简单文件加密工具
代码来自GitHub,我对其进行了一定的优化和修改,可用于百度网盘防炸。
全部文件(包括编译后的单个EXE)
เว็บลิงค์(pan.baidu.com)?pwd=c22f
其中EXE文件可以独立运行,免安装,无需环境。
主程序代码:
import sys
from tkinter import *
from tkinter import filedialog
from tkinter import ttk
import เว็บลิงค์(tkinter.ttk)
import threading
from binascii import a2b_hex
from binascii import b2a_hex
import เว็บลิงค์(tkinter.messagebox)
import os
import shutil
import เว็บลิงค์(tkinter.scrolledtext)
import multiprocessing
from multiprocessing import Queue
from multiprocessing import Process
import base64
from เว็บลิงค์(crypto.cipher) import AES
from เว็บลิงค์(crypto.random) import get_random_bytes
from i import img
def read(dir,address,length,f):
เว็บลิงค์(f.seek)(address, 0)
result = เว็บลิงค์(f.read)(length)
result = b2a_hex(result)
result = เว็บลิงค์(bytes.decode)(result)
return result
def write(write_bytes,dir,address,f):
try:
write_bytes = bytes().fromhex(write_bytes)
except:
print(write_bytes)
เว็บลิงค์(f.seek)(address, 0)
result=เว็บลิงค์(f.write)(write_bytes)
return result
def realcode1(dir,mima,mima_len,flagmi):
def jiamihanshu(mima, readdata, iv):
secret = mima # 由用户输入的16位或24位或32位长的初始密码字符串
# 密钥处理,16的整数倍
def add_to_16(text):
while len(text) % 16 != 0:
text += '\0'
return (text)
secret = add_to_16(secret)
iv = bytes().fromhex(iv)
cipher = เว็บลิงค์(aes.new)(เว็บลิงค์(secret.encode)('utf-8'), AES.MODE_CBC, iv)
data = readdata # 16beishu
data = bytes().fromhex(data)
try :
encrypt_data = เว็บลิงค์(cipher.encrypt)(data) # 输入需要加密的字符串,注意字符串长度要是16的倍数。16,32,48..
encrypt_data = เว็บลิงค์(bytes.decode)(b2a_hex(encrypt_data))
return encrypt_data
except:
return เว็บลิงค์(bytes.decode)(b2a_hex(data))
def jiemihanshu(mima, readdata, iv):
secret = mima # 由用户输入的16位或24位或32位长的初始密码字符串
def add_to_16(text):
while len(text) % 16 != 0:
text += '\0'
return (text)
secret = add_to_16(secret)
iv = bytes().fromhex(iv) # 随机获取16位变量
encrypt_data = bytes().fromhex(readdata)
cipher = เว็บลิงค์(aes.new)(เว็บลิงค์(secret.encode)('utf-8'), AES.MODE_CBC, iv)
try:
decrypt_data = เว็บลิงค์(cipher.decrypt)(encrypt_data)
decrypt_data = เว็บลิงค์(bytes.decode)(b2a_hex(decrypt_data))
return decrypt_data
except:
return เว็บลิงค์(bytes.decode)(b2a_hex(encrypt_data))
f = open(dir, "rb+")
file_stats = เว็บลิงค์(os.stat)(dir)
max = int(file_stats.st_size)
i = 0
while True:
a = read(dir, i,32, f)
if flagmi == 1:
abc = jiamihanshu(mima,a,"20060815200608152006081520060815")
if flagmi == 2:
abc = jiemihanshu(mima,a,"20060815200608152006081520060815")
write(abc,dir,i,f)
i += 1024
เว็บลิงค์(bar1.step)(1024)
เว็บลิงค์(root.update)()
if i+1024>=(min(max,10000000)):
เว็บลิงค์(f.close)()
break
def coding(dir,mima,mima_len,flagmi):
file_stats = เว็บลิงค์(os.stat)(dir)
max = int(file_stats.st_size)
realcode1(dir,mima,mima_len,flagmi,)
def jiami(dir,save_dir,mima,mima_len):
เว็บลิงค์(shutil.copyfile)(dir,save_dir)
coding(save_dir,mima,mima_len,1)
def jiemi(dir,save_dir,mima,mima_len):
เว็บลิงค์(shutil.copyfile)(dir, save_dir)
coding(save_dir,mima,mima_len,2)
def function1():
global file2,singleflag
OpenFile = Tk() #创建新窗口
เว็บลิงค์(openfile.withdraw)()
file_path2 = เว็บลิงค์(filedialog.askopenfilenames)(filetypes=[('加密文件(*.ghl)','.ghl')]) # 获取路径
เว็บลิงค์(a3.configure)(state='normal')
เว็บลิงค์(a3.delete)(0, 'end')
เว็บลิงค์(a3.insert)(INSERT, file_path2)
เว็บลิงค์(a3.configure)(state='disable')
file2 = file_path2
singleflag = 1
def function2():
global file1,singleflag
OpenFile = Tk() #创建新窗口
เว็บลิงค์(openfile.withdraw)()
file_path1 = เว็บลิงค์(filedialog.askopenfilenames)() # 获取路径
เว็บลิงค์(a2.configure)(state='normal')
เว็บลิงค์(a2.delete)(0, 'end')
เว็บลิงค์(a2.insert)(INSERT, file_path1)
เว็บลิงค์(a2.configure)(state='disable')
file1 = file_path1
singleflag = 1
def functionjia():
global file1,singleflag
OpenFile = Tk() # 创建新窗口
เว็บลิงค์(openfile.withdraw)()
file_path1 = เว็บลิงค์(filedialog.askdirectory)()
file1 = ()
for root1, dirs, files in เว็บลิงค์(os.walk)(file_path1, topdown=False):
for a in files:
newroot = ''
for evestr in root1:
if evestr == '\\':
newroot+='/'
else:
newroot+=evestr
file1+=(newroot+'/'+a,)
เว็บลิงค์(a2.configure)(state='normal')
เว็บลิงค์(a2.delete)(0, 'end')
เว็บลิงค์(a2.insert)(INSERT, file_path1)
เว็บลิงค์(a2.configure)(state='disabled')
singleflag = 0
def functionjie():
global file2,singleflag
OpenFile = Tk() # 创建新窗口
เว็บลิงค์(openfile.withdraw)()
file_path2 = เว็บลิงค์(filedialog.askdirectory)()
file2 = ()
for root1, dirs, files in เว็บลิงค์(os.walk)(file_path2, topdown=False):
for a in files:
newroot = ''
for evestr in root1:
if evestr == '\\':
newroot += '/'
else:
newroot += evestr
file2 += (newroot + '/'+a,)
เว็บลิงค์(a3.configure)(state='normal')
เว็บลิงค์(a3.delete)(0, 'end')
เว็บลิงค์(a3.insert)(INSERT, file_path2)
เว็บลิงค์(a3.configure)(state='disabled')
singleflag = 0
def function3():#jiami
global file1,log,singleflag
if singleflag == 0:
mima = เว็บลิงค์(a1.get)()
newmima = ''
for i in mima:
newmima = newmima+str(ord(i))
mima = newmima
mima_len = len(mima)
cha = 1024
save_dir = เว็บลิงค์(filedialog.askdirectory)(initialdir=เว็บลิงค์(a2.get)())
print(save_dir)
for everypath in file1:
if save_dir!='':
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '正在加密'+save_dir+everypath[len(เว็บลิงค์(a2.get)()):])
เว็บลิงค์(log.configure)(state='disabled')
เว็บลิงค์(root.update)()
if not เว็บลิงค์(os.path.exists)(save_dir+everypath[len(เว็บลิงค์(a2.get)()):เว็บลิงค์(everypath.rfind)('/')]):
เว็บลิงค์(os.makedirs)(save_dir+everypath[len(เว็บลิงค์(a2.get)()):เว็บลิงค์(everypath.rfind)('/')])
file_stats = เว็บลิงค์(os.stat)(everypath)
bar1['maximum'] = min(int(file_stats.st_size),10000000) + 1
jiami(everypath,save_dir+everypath[len(เว็บลิงค์(a2.get)()):]+'.ghl',mima,mima_len)
bar1['value'] = 0
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, ' 完成!' + '\n')
log.mark_set("insert", "end")
เว็บลิงค์(log.see)("insert")
เว็บลิงค์(log.configure)(state='disabled')
เว็บลิงค์(root.update)()
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '加密完成!所有文件均输出至' +save_dir+ '\n')
เว็บลิงค์(log.configure)(state='disabled')
elif singleflag==1:
mima = เว็บลิงค์(a1.get)()
newmima = ''
for i in mima:
newmima = newmima + str(ord(i))
mima = newmima
mima_len = len(mima)
cha = 1024
save_dir = เว็บลิงค์(filedialog.askdirectory)(initialdir=file1[0][:file1[0].rfind('/')])
for everypath in file1:
if save_dir != '':
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '正在加密' + save_dir + everypath[เว็บลิงค์(everypath.rfind)('/'):])
เว็บลิงค์(log.configure)(state='disabled')
เว็บลิงค์(root.update)()
file_stats = เว็บลิงค์(os.stat)(everypath)
bar1['maximum'] = min(int(file_stats.st_size), 10000000) + 1
jiami(everypath, save_dir + everypath[เว็บลิงค์(everypath.rfind)('/'):] + '.ghl', mima, mima_len)
bar1['value'] = 0
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, ' 完成!' + '\n')
log.mark_set("insert", "end")
เว็บลิงค์(log.see)("insert")
เว็บลิงค์(log.configure)(state='disabled')
เว็บลิงค์(root.update)()
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '加密完成!所有文件均输出至' + save_dir + '\n')
เว็บลิงค์(log.configure)(state='disabled')
def function4():#jiemi
global file2,log,singleflag
if singleflag==0:
mima = เว็บลิงค์(a1.get)()
newmima = ''
for i in mima:
newmima = newmima+str(ord(i))
mima = newmima
mima_len = len(mima)
cha = 1024
save_dir = เว็บลิงค์(filedialog.askdirectory)(initialdir=เว็บลิงค์(a3.get)())
for everypath in file2:
if save_dir!='':
if everypath[เว็บลิงค์(everypath.rfind)('.'):]=='.ghl':
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '正在解密' + save_dir + everypath[len(เว็บลิงค์(a3.get)()):])
เว็บลิงค์(log.configure)(state='disabled')
if not เว็บลิงค์(os.path.exists)(save_dir + everypath[len(เว็บลิงค์(a3.get)()):เว็บลิงค์(everypath.rfind)('/')]):
เว็บลิงค์(os.makedirs)(save_dir + everypath[len(เว็บลิงค์(a3.get)()):เว็บลิงค์(everypath.rfind)('/')])
file_stats = เว็บลิงค์(os.stat)(everypath)
bar1['maximum'] = min(int(file_stats.st_size),10000000) + 1
jiemi(everypath,save_dir+everypath[len(เว็บลิงค์(a3.get)()):เว็บลิงค์(everypath.rfind)('.')],mima,mima_len)
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, ' 完成!' + '\n')
log.mark_set("insert", "end")
เว็บลิงค์(log.see)("insert")
เว็บลิงค์(log.configure)(state='disabled')
bar1['value'] = 0
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '解密完成!所有文件均输出至' + save_dir + '\n')
เว็บลิงค์(log.configure)(state='disabled')
elif singleflag==1:
mima = เว็บลิงค์(a1.get)()
newmima = ''
for i in mima:
newmima = newmima + str(ord(i))
mima = newmima
mima_len = len(mima)
cha = 1024
save_dir = เว็บลิงค์(filedialog.askdirectory)(initialdir=file2[0][:file2[0].rfind('/')])
for everypath in file2:
if save_dir != '':
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '正在解密' + save_dir + everypath[เว็บลิงค์(everypath.rfind)('/'):])
เว็บลิงค์(log.configure)(state='disabled')
file_stats = เว็บลิงค์(os.stat)(everypath)
bar1['maximum'] = min(int(file_stats.st_size), 10000000) + 1
jiemi(everypath, save_dir + everypath[เว็บลิงค์(everypath.rfind)('/'):เว็บลิงค์(everypath.rfind)('.')], mima, mima_len)
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, ' 完成!' + '\n')
log.mark_set("insert", "end")
เว็บลิงค์(log.see)("insert")
เว็บลิงค์(log.configure)(state='disabled')
bar1['value'] = 0
เว็บลิงค์(log.configure)(state='normal')
เว็บลิงค์(log.insert)(INSERT, '解密完成!所有文件均输出至' + save_dir + '\n')
เว็บลิงค์(log.configure)(state='disabled')
if __name__ == '__main__':
picture = open("เว็บลิงค์(picture.ico)", "wb+")#载入图标
เว็บลิงค์(picture.write)(base64.b64decode(img))
เว็บลิงค์(picture.close)()
multiprocessing.freeze_support()
singleflag = 2
root = Tk()
เว็บลิงค์(root.title)('文件解密工具')
เว็บลิงค์(root.iconbitmap)('เว็บลิงค์(picture.ico)')
เว็บลิงค์(os.remove)("เว็บลิงค์(picture.ico)")
เว็บลิงค์(root.minsize)(560, 420)
#เว็บลิงค์(root.maxsize)(560, 420)
เว็บลิงค์(root.protocol)("WM_DELETE_WINDOW", lambda: เว็บลิงค์(sys.exit)(0))
L1 = Label(root, text="密码:",width=10,font=("Calibri 16"))
a1 = Entry(root,width=20,font=("Calibri 16"))
Lth = Label(root, text="使用进程数:",width=10)
ath = Entry(root,width=20,font=("Calibri 16"))
L2 = Label(root, text="加密:",width=10,font=("Calibri 16"))
a2 = Entry(root,width=20,font=("Calibri 16"))
b = Button(root,text='浏览文件',command=function2,width=10,font=("Calibri 16"))
b1 = Button(root,text='浏览文件夹',command=functionjia,width=10,font=("Calibri 16"))
c = Button(root,text='加密',command=function3,width=10,font=("Calibri 16"))
L3 = Label(root, text="解密:",width=10,font=("Calibri 16"))
a3 = Entry(root,width=20,font=("Calibri 16"))
d = Button(root,text='浏览文件',command=function1,width=10,font=("Calibri 16"))
d1 = Button(root,text='浏览文件夹',command=functionjie,width=10,font=("Calibri 16"))
e = Button(root,text='解密',command=function4,width=10,font=("Calibri 16"))
bar1 = เว็บลิงค์(tkinter.ttk.progressbar)(root,length = 550)
log = เว็บลิงค์(tkinter.scrolledtext.scrolledtext)(root, width=85, height=20)
เว็บลิงค์(l1.grid)(row=0,column=0)
เว็บลิงค์(a1.grid)(row=0,column=1) # 将小部件放置到主窗口中
เว็บลิงค์(a1.delete)(0, "end")
เว็บลิงค์(a1.insert)(0, "เว็บลิงค์(ghacg.com)")
#
เว็บลิงค์(b.grid)(row=1,column=2)
#
เว็บลิงค์(b1.grid)(row=1,column=3)
#
เว็บลิงค์(c.grid)(row=1,column=4)
เว็บลิงค์(d.grid)(row=2,column=2)
#
เว็บลิงค์(d1.grid)(row=2, column=3)
เว็บลิงค์(e.grid)(row=2,column=4)
#
เว็บลิงค์(l2.grid)(row=1,column=0)
เว็บลิงค์(l3.grid)(row=2,column=0)
#
เว็บลิงค์(a2.grid)(row=1,column=1)
เว็บลิงค์(a3.grid)(row=2,column=1)
เว็บลิงค์(bar1.grid)(row=3,column=0,columnspan=5)
เว็บลิงค์(log.grid)(row=4,column=0,columnspan=5)
เว็บลิงค์(ath.insert)(INSERT, 4)
เว็บลิงค์(log.configure)(state='disabled')
เว็บลิงค์(a3.configure)(state='disabled')
เว็บลิงค์(a2.configure)(state='disabled')
เว็บลิงค์(root.mainloop)() # 进入消息循环
效果展示
全部文件(包括编译后的单个EXE)
เว็บลิงค์(pan.baidu.com)?pwd=c22f
其中EXE文件可以独立运行,免安装,无需环境。คำประกาศบทความทั้งหมดบนเว็บไซต์นี้ หากไม่มีการระบุหรือทำเครื่องหมายเป็นอย่างอื่น ล้วนเป็นสิ่งพิมพ์ต้นฉบับของเว็บไซต์นี้ บุคคลหรือองค์กรใด ๆ ห้ามคัดลอก ขโมย รวบรวม หรือเผยแพร่เนื้อหาของเว็บไซต์นี้ไปยังเว็บไซต์ หนังสือ หรือแพลตฟอร์มสื่ออื่น ๆ โดยไม่ได้รับความยินยอมจากนายอัพโหลด หากเนื้อหาของเว็บไซต์นี้ละเมิดสิทธิและผลประโยชน์ที่ถูกต้องของผู้เขียนต้นฉบับ กรุณาติดต่อเราเพื่อดำเนินการ: รายงาน DMCA













ผู้ชายคนนี้ดูเหมือนจะขี้อายมาก (Bushi
Howdy!
ผู้ชายคนนี้ดูเหมือนจะขี้อายมาก (Bushi
月厨,公主厨,不搞拔作。