Metadata-Version: 2.1
Name: se-import
Version: 0.0.8
Summary: se-import: Modules import in a safe source protection, support for python module code and custom des encryption, ase decryption operation or custom decryption callback module loading
Home-page: https://github.com/ssbuild
Author: ssbuild
Author-email: 9727464@qq.com
License: Apache 2.0
Keywords: se_import,se import,se-import
Platform: win32_AMD64
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3, <4
Description-Content-Type: text/markdown
Requires-Dist: fastcrypto (<1.0.0,>=0.0.1)

se-import: Modules import in a safe source protection, support for python module code and custom des encryption, ase decryption operation or custom decryption callback module loading

```py
# -*- coding: utf-8 -*-
# @Time    : 2021/11/10 11:22
'''
    模块的安全导入，对python模块代码支持des和自定义加密，运行des解密或者自定义解密回调
'''
```
se_import demo:
```py
# -*- coding: utf-8 -*-
# @Time    : 2021/11/9 16:42

import sys
import se_import
print(dir(se_import))

#从内存加载模块
def test_load_mem():
    s = "a = 100\nb=1000"
    #自定义模块名
    name = 'test_load_mem_test'
    ret = se_import.load_module(name,s,name + '.py')
    print(ret)
    print(dir(ret))
    print(ret.a)
    print(ret.b)

#从内存加载模块，支持模块解密回调
def test_load_custom():
    #从内存加载模块
    s = "a = 100\nb=1000"
    # 自定义模块名
    name = 'load_module_custom_test'
    ret= se_import.load_module_custom(name,s,name + '.py',lambda x:x + '\nadasdadada=1000')
    print(ret)
    print(dir(ret))
    print(ret.a)
    print(ret.b)

#从本地 ase加密文件加载模块
def test_save_load_asefile():

    #模块ase 加密，保存到文件
    infile = "./ase.py"
    outfile = './ase.pys'
    key = bytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
    iv = bytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
    #第一个参数类型是字符串 是文件名， bytes 则为二进制文件内容
    ret = se_import.dump_module_to_asefile(infile, key, iv)
    with open(outfile,mode='wb') as f:
        f.write(ret)

    #从文件加载加密模块
    # 自定义模块名
    infile = './ase.pys'
    name = 'test_save_load_asefile_test'
    ret2 = se_import.load_module_from_asefile(name,infile,name + '.py')
    print(ret2)
    print(dir(ret2))

if __name__ == '__main__':
    test_save_load_asefile()
```


