脚本加密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)
混淆项目代码步骤:
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16