脚本加密python
Posted 朝阳的向日葵
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了脚本加密python相关的知识,希望对你有一定的参考价值。
from pathlib import Path import python_minifier import compileall import sys def get_save_path(from_dir, to_dir, p): ori_dir = str(from_dir.resolve()) _p = str(p.resolve()) return to_dir.joinpath(_p.split(ori_dir)[-1][1:]) def mix_pyminifier(from_dir, to_dir): for _p in from_dir.rglob(\'*.py\'): with _p.open(encoding=\'utf-8\') as read_fp: res = python_minifier.minify(read_fp.read()) _to_p = get_save_path(from_dir, to_dir, _p) Path(_to_p.parent).mkdir(exist_ok=True, parents=True) with _to_p.open(\'w\', encoding=\'utf-8\') as write_fp: write_fp.write(res) def py2pyc(from_dir, to_dir): compileall.compile_dir(str(from_dir.resolve()), maxlevels=20, force=True) def pyc2py(from_dir, to_dir): pass if __name__ == \'__main__\': origin_dir = Path(sys.argv[1]) target_dir = Path(sys.argv[2]) pymini_dir = target_dir.joinpath(\'pymini\') pyc_dir = target_dir.joinpath(\'pyc_dir\') py_dir = target_dir.joinpath(\'py_dir\') mix_pyminifier(origin_dir, target_dir) # py2pyc(origin_dir, pyc_dir) # pyc2py(pyc_dir, pyc_dir)
混淆项目代码步骤:
以上是关于脚本加密python的主要内容,如果未能解决你的问题,请参考以下文章
实用脚本!利用 Python 对 PDF 进行加密解密操作,代码拿走就用!