
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
se-import
Advanced tools
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
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
# -*- coding: utf-8 -*-
# @Time : 2021/11/10 11:22
'''
模块的安全导入,对python模块代码支持des和自定义加密,运行des解密或者自定义解密回调
'''
se_import demo:
# -*- 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()
FAQs
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
We found that se-import demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.