Skip to main content

py-gen-mur

python 机器码/用户码/注册码 生成器
python generate [m]achine_code [u]ser_code [r]egister_code


运行环境

因内含 win32api 依赖包,该包在 Linux 环境下安装会报错,不必理会,不影响使用

使用场景说明

使用场景详见 测试用例

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

因代码开源,不建议使用 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)

开发者说明

展开

手动打包项目

每次修改代码后,记得同步修改 setup.py 下的版本号 version='x.y.z'

# 构建用于发布到 PyPI 的压缩包
python setup.py sdist

# 本地安装(测试用)
pip install .\dist\py-gen-mur-?.?.?.tar.gz

# 本地卸载
pip uninstall py-gen-mur

手动发布项目

首先需要在 PyPI 上注册一个帐号,并在本地用户根目录下创建文件 ~/.pypirc(用于发布时验证用户身份),其内容如下:

[distutils]
index-servers=pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = <username>
password = <password>

其次安装 twine 并上传项目:

# 首次发布需安装
pip install twine

# 发布项目, 若发布成功可在此查看 https://pypi.org/manage/projects/
twine upload dist/*

发布到 PyPI 的项目名称必须是全局唯一的,即若其他用户已使用该项目名称,则无法发布(报错:The user 'xxx' isn't allowed to upload to project 'yyy'.)。此时只能修改 setup.py 下的项目名称 name

本项目已集成了 Github Workflows,每次推送更新到 master 即可自动打包并发布到 PyPI

关于测试

详见 单元测试说明

参考资料

赞助途径

支付宝 微信

版权声明

 Copyright (C) EXP,2016 License: GPL v3


Release files for py-gen-mur 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-gen-mur 1.0.1
File Size Uploaded
py-gen-mur-1.0.1.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-gen-mur 1.0.1
File Interpreter ABI Platform
py_gen_mur-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.7 kB

Release files / py-gen-mur-1.0.1.tar.gz

Download URL py-gen-mur-1.0.1.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c1193aeb0076bfa73dacb46c9a52c199c039378cedf47acbfad47ed6a5af9b90
BLAKE2b-256 checksum
How to use checksums
b8cd7a25ee2db001d0560ebafa9708204afb2b00fe468dc8c5a6139112ef1c54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / py_gen_mur-1.0.1-py3-none-any.whl

Download URL py_gen_mur-1.0.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
830639c38404c97670d40fec03ef06b0bdeb6f37baea1d234926715177434541
BLAKE2b-256 checksum
How to use checksums
03a3aeeadf85d0ee0be5fa3f7a1afa69c78c49e2d27a11ee35485f879adc0c41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page