From b17f67bc7e739f247442e1e0e1f6b8848d7a7365 Mon Sep 17 00:00:00 2001 From: cforth Date: Thu, 30 Jan 2020 15:19:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A0=E5=AF=86=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8D=E7=A7=B0=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cryptor.py | 11 +++++++++++ libs/CFCrypto.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cryptor.py b/Cryptor.py index 18f02b2..443cf6f 100644 --- a/Cryptor.py +++ b/Cryptor.py @@ -461,10 +461,21 @@ def run_task(self): if crypto_option == "加密预览": if data_option == "文件" or data_option == "文件夹" and is_handle_name: DirShowHandle(self, self.tree, input_text, lambda x: StringCrypto(password).encrypt(x)).start() + elif data_option == "文件夹名称": + DirShowHandle(self, self.tree, input_text, lambda x: get_str_md5(StringCrypto(password).encrypt(x))).start() elif crypto_option == "解密预览": if data_option == "文件" or data_option == "文件夹" and is_handle_name: DirShowHandle(self, self.tree, input_text, lambda x: StringCrypto(password).decrypt(x)).start() + elif data_option == "文件夹名称": + # 读取文件名MD5值字典 + input_dir_name = os.path.basename(os.path.abspath(input_text)) + encrypt_config_name = get_str_md5(StringCrypto(password).encrypt(input_dir_name)) + ".json" + config_file = os.path.join(os.path.dirname(os.path.abspath(input_text)), encrypt_config_name) + file_name_md5_dict = {} + with open(config_file, "r") as f: + file_name_md5_dict = json.load(f) + DirShowHandle(self, self.tree, input_text, lambda x: StringCrypto(password).decrypt(file_name_md5_dict[x])).start() elif data_option == "字符串": if crypto_option == "加密": diff --git a/libs/CFCrypto.py b/libs/CFCrypto.py index cadb373..5bcf19a 100644 --- a/libs/CFCrypto.py +++ b/libs/CFCrypto.py @@ -375,7 +375,7 @@ def decrypt(self, file_path, output_file_path): f.write(data) -# 文件假名称加密解密类 +# 文件夹名称加密解密类 class DirNameCrypto(object): def __init__(self, password, config_file=None): self.string_crypto = StringCrypto(password)