Skip to content

Commit

Permalink
增加加密解密文件夹名称预览
Browse files Browse the repository at this point in the history
  • Loading branch information
cforth committed Jan 30, 2020
1 parent 398d43b commit b17f67b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Cryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "加密":
Expand Down
2 changes: 1 addition & 1 deletion libs/CFCrypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b17f67b

Please sign in to comment.