python generate machine_code, user_code, register_code
Project description
py-gen-mur
python 机器码/用户码/注册码 生成器
python generate [m]achine_code [u]ser_code [r]egister_code
运行环境
使用注意
凡是使用了此工具的程序,在发布该程序时,建议不要直接用 Pyinstaller
打包成 *.pyc
,然后供用户使用,否则很容易被反编译破解。
建议先对源码做加密处理,有两个方法,任选一个即可:
- 使用
Pyinstaller
打包时增加--key ${password}
参数,对源码加密,得到*.pyc.encrypted
后才提供给用户使用。
- 先使用
Cython
生成*.py
的动态连接*.pyd
文件,再使用Pyinstaller
打包,才供用户使用。
可参考文档《Cython + Pyinstaller 防止反编译打包》
使用场景说明
使用场景详见 测试用例 。
场景步骤一(管理员本地,可选)
因代码开源,不建议使用 mur.crypt.Crypt()
默认类。
建议使用此工具时,自定义指定 mur.crypt.Crypt()
构造函数的 key
和 iv
。
本代码中提供了 mur.crypt.gen_des_key()
和 mur.crypt.gen_des_iv()
的方法,但是生成后必须找地方另外存储这两个值,否则之前使用其生成的注册码无法再解密。
from mur.crypt import *
my_des_key = gen_des_key()
my_des_iv = gen_des_key()
my_crypt = Crypt(
key = my_des_iv,
iv = my_des_iv
)
场景步骤二(用户本地)
- 用户运行【生成机器码】的程序
- 生成放有【加密机器码】的文件
- 把【加密机器码】的文件提供给管理员
from mur.user import *
u_machine_code = gen_machine_code(my_crypt)
实际使用时可复制
gen_register_code.py
到需要发布的程序,由用户执行生成【机器码】
场景步骤三(管理员本地)
- 管理员解密用户提供的【加密机器码】文件
- 同时为用户设置授权天数,生成【用户码】文件
- 结合两者生成【注册码】文件
- 把【用户码】文件和【注册码】文件提供给用户
from mur.admin import *
a_machine_code = read_machine_code()
days = input('请输入授权天数:') # 0 表示永久
a_user_code = gen_user_code(days, my_crypt)
a_register_code = gen_register_code(
a_machine_code, a_user_code, my_crypt
)
实际使用时可在本仓库中执行
python gen_register_code.py
为用户生成【用户码】和【注册码】
场景步骤四(用户本地)
- 用户运行应用主程序
- 主程序读取【用户码】文件(或让用户输入用户码)
- 主程序在用户本地重新生成【机器码】
- 主程序利用【用户码】和【机器码】生成【注册码】
- 主程序比对【生成的注册码】和【管理员提供的注册码】内容是否一致
- 若一致,且授权未过期,程序运行;否则,程序终止
from mur.user import *
u_user_code = read_user_code()
rst = verify_authorization(u_user_code, my_crypt)
if rst == True :
app.run()
else :
exit(1)
赞助途径
支付宝 | 微信 |
---|---|
版权声明
- Site: http://exp-blog.com
- Mail: 289065406@qq.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-gen-mur-1.1.4.tar.gz
(14.1 kB
view hashes)
Built Distribution
py_gen_mur-1.1.4-py3-none-any.whl
(11.0 kB
view hashes)
Close
Hashes for py_gen_mur-1.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a5c777fe4ac9ceb91d8660ba42500bb5af8334c567fb53b76e5788e6f08cf03 |
|
MD5 | 18059ed9dd9329ed61ebcb77312521d6 |
|
BLAKE2b-256 | 60d5e53f49482c244f431b66914f1a79858eeb7695acb3eebdbbaccc9f8b032e |