Django專案中所有.py 檔案加密
阿新 • • 發佈:2021-12-23
import py_compile import os class EncryptionProject: def __init__(self, file_path): self.filepath = file_path def read_project(self): filepath = os.getcwd() + self.filepath encry_list = [] for dirpath, dirnames, files in os.walk(filepath): if len(files) > 0:for i in files: if len(i) > 0: if i.split(".")[1] == 'py': encry_list.append(dirpath + "\\" + i) else: if len(files) > 0: if files.split(".")[1] == 'py': encry_list.append(dirpath+ "\\" + files) return encry_list def encryption_project(self): encry_list = self.read_project() for i in encry_list: py_compile.compile(i) return "加密成功" if __name__ == "__main__": file_path = "\\test\CIA_Test01" result = EncryptionProject(file_path).encryption_project()print(result)