码迷,mamicode.com
首页 > 编程语言 > 详细

脚本加密python

时间:2019-12-27 11:52:07      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:代码   rom   class   mkdir   target   image   alt   ORC   max   

技术图片

 

  

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

标签:代码   rom   class   mkdir   target   image   alt   ORC   max   

原文地址:https://www.cnblogs.com/zknublx/p/12106131.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!