se_code 对python源代码代码加密保护,带密运行
# -*- coding: utf-8 -*-
# @Time : 2021/11/11 14:42
# @Author : wyw
import shutil
'''
2021-11-18 修改demo 注释说明
2021-11-12 新增功能:
se_single 对整个工程代码加密成单独文件可避免模块结构暴露 , 只会加密代码部分,加密后产生的代码空目录不能删除,
1. se_project 工程加密处理:
源码工程目录参考示例
/home/project
script
run.sh
...
serving # 源码目录
config
config.py
...
utils
...
runner.py #程序主入口 main()
2. 注册运行解析器
se_register_module(root_dir)
root_dir 加密工程根路径 上例root_dir目录: /home/project_se
'''
#package_name 如果制作.whl , 自定义设置包,否则默认为包含代码的最近目录名
def test_se_project(src_dir = '/home/project',dst_dir = '/home/project_se' , package_name=None,ext='.pys'):
from se_code import se_project
#目标文件夹存在则自动删除
dst_exists_remove = False
#对工程代码加密成单独文件
se_single = False
#忽略复制文件,文件对工程运行没有用
ignore = shutil.ignore_patterns('test','.git','.idea','setup.py')
#package_name
# 如果是pypi包,package_name 需要设置包名,否则可以设置None
#加密接受规则
rules = ['serving/utils/*', 'serving/run*', 'serving/http_client/http*']
se_project(src_dir,
dst_dir,
package_name=package_name,
ext=ext,
dst_exists_remove=dst_exists_remove,
se_single=se_single,
ignore = ignore,
rules = rules,
key=bytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),
iv=bytes([1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
)
def run():
# 如果是pip 包加密,例如包名为 nn_serving , module_root_dir=os.path.dirname(nn_serving.__file__)
# demo 对于此示例 /home/project_se/serving/start.py , 代码模块都在 /home/project_se/serving, module_root_dir=/home/project_se/serving
import sys,os
sys.path.append('..')
from se_code import se_register_module
#root_dir目录下必须存在__meta__目录下必须存在__meta__.pys
#root_dir='/home/project_se'
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir))
se_register_module(root_dir=root_dir)
from serving.runner import main
main()
Metadata
Release files for se-code 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| se_code-0.2.8-py3-none-any.whl | Python 3 | none | any | Details for se_code-0.2.8-py3-none-any.whl |
Release files / se_code-0.2.8-py3-none-any.whl
| Download URL | se_code-0.2.8-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4892360247d5ae5547428c4d5e850c1452da9d78c3829195e294a4172347e8b0
|
|
BLAKE2b-256 checksum How to use checksums |
ced344251c99a065056edd3bcc52b52644a734c16b2f40c87b9ed73f59f2eb3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9
|
Security for se-code 0.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.