Skip to main content

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,然后供用户使用,否则很容易被反编译破解。

建议先对源码做加密处理,有两个方法,任选一个即可:

  1. 使用 Pyinstaller 打包时增加 --key ${password} 参数,对源码加密,得到 *.pyc.encrypted 后才提供给用户使用:可参考文档《Pyinstaller 打包的 exe 之一键反编译 py 脚本与防反编译
  2. 先使用 Cython 生成 *.py 的动态连接 *.pyd 文件,再使用 Pyinstaller 打包,才供用户使用:可参考文档《Cython + Pyinstaller 防止反编译打包

使用场景说明

使用场景详见 测试用例

场景步骤一(管理员本地,可选)

因代码开源,不建议使用 mur.crypt.Crypt() 默认类。

建议使用此工具时,自定义指定 mur.crypt.Crypt() 构造函数的 keyiv

本代码中提供了 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
)

场景步骤二(用户本地)

  1. 用户运行【生成机器码】的程序
  2. 生成放有【加密机器码】的文件
  3. 把【加密机器码】的文件提供给管理员
from mur.user import *

u_machine_code = gen_machine_code(my_crypt)

场景步骤三(管理员本地)

  1. 管理员解密用户提供的【加密机器码】文件
  2. 同时为用户分配【随机用户码】文件
  3. 结合两者生成【注册码】文件
  4. 把【随机用户码】文件和【注册码】文件提供给用户
from mur.admin import *

a_machine_code = read_machine_code()
a_user_code = gen_user_code()
a_register_code = gen_register_code(
    a_machine_code, a_user_code, my_crypt
)

场景步骤四(用户本地)

  1. 用户运行应用主程序
  2. 主程序读取【用户码】文件(或让用户输入用户码)
  3. 主程序在用户本地重新生成【机器码】
  4. 主程序利用【用户码】和【机器码】生成【注册码】
  5. 主程序比对【生成的注册码】和【管理员提供的注册码】内容是否一致
  6. 若一致,程序运行;否则,程序终止
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)

赞助途径

支付宝 微信

版权声明

 Copyright (C) EXP,2016 License: GPL v3


Project details


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.0.3.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distribution

py_gen_mur-1.0.3-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page