{"id":23087627,"url":"https://github.com/exp-codes/py-gen-mur","last_synced_at":"2025-12-14T14:27:17.518Z","repository":{"id":61842233,"uuid":"441928582","full_name":"EXP-Codes/py-gen-mur","owner":"EXP-Codes","description":"python 机器码/用户码/注册码 生成器","archived":false,"fork":false,"pushed_at":"2023-04-12T02:41:04.000Z","size":188,"stargazers_count":43,"open_issues_count":0,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-19T07:36:59.443Z","etag":null,"topics":["generate","machine","programming","pypi","python","register","user"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/py-gen-mur/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EXP-Codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"exppoc","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://lyy289065406.github.io/sponsor/"]}},"created_at":"2021-12-26T15:54:56.000Z","updated_at":"2024-10-09T14:52:52.000Z","dependencies_parsed_at":"2023-02-10T05:16:03.569Z","dependency_job_id":"cc15a1bb-864d-4e7a-84e3-eb8d8ba9a368","html_url":"https://github.com/EXP-Codes/py-gen-mur","commit_stats":null,"previous_names":["lyy289065406/py-gen-mur"],"tags_count":1,"template":false,"template_full_name":"EXP-Codes/pypi-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpy-gen-mur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpy-gen-mur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpy-gen-mur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpy-gen-mur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EXP-Codes","download_url":"https://codeload.github.com/EXP-Codes/py-gen-mur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230019707,"owners_count":18160587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generate","machine","programming","pypi","python","register","user"],"created_at":"2024-12-16T19:59:20.419Z","updated_at":"2025-12-14T14:27:17.420Z","avatar_url":"https://github.com/EXP-Codes.png","language":"Python","readme":"# py-gen-mur\n\n\u003e python 机器码/用户码/注册码 生成器\n\u003cbr/\u003e python generate [m]achine_code [u]ser_code [r]egister_code\n\n------\n\n## 运行环境\n\n![](https://img.shields.io/badge/Python-3.8%2B-brightgreen.svg)\n\n\n## 安装说明\n\n执行脚本： \n\n```\npython -m pip install --upgrade pip\npython -m pip install py-gen-mur\n```\n\n\n## 使用场景说明\n\n\u003e 使用场景详见 [测试用例](./tests/test.py) 。\n\n\n### 场景步骤一（管理员本地，可选）\n\n因代码开源，不建议使用 `mur.crypt.Crypt()` 默认类。\n\n建议使用此工具时，自定义指定 `mur.crypt.Crypt()` 构造函数的 `key` 和 `iv` 。\n\n本代码中提供了 `mur.crypt.gen_des_key()` 和 `mur.crypt.gen_des_iv()` 的方法，但是生成后必须找地方另外存储这两个值，否则之前使用其生成的注册码无法再解密。\n\n```python\nfrom mur.crypt import *\n\nmy_des_key = gen_des_key()\nmy_des_iv = gen_des_key()\n\nmy_crypt = Crypt(\n    key = my_des_iv, \n    iv = my_des_iv\n)\n```\n\n\n### 场景步骤二（用户本地）\n\n1. 用户运行【生成机器码】的程序\n2. 生成放有【加密机器码】的文件\n3. 把【加密机器码】的文件提供给管理员\n\n\n```python\nfrom mur.user import *\n\nu_machine_code = gen_machine_code(my_crypt)\n```\n\n\u003e 实际使用时可复制 [`gen_machine_code.py`](./gen_machine_code.py) 到需要发布的程序，由用户执行生成【机器码】\n\n\n### 场景步骤三（管理员本地）\n\n1. 管理员解密用户提供的【加密机器码】文件\n2. 同时为用户设置授权天数，生成【用户码】文件\n3. 结合两者生成【注册码】文件\n4. 把【用户码】文件和【注册码】文件提供给用户\n\n```python\nfrom mur.admin import *\n\na_machine_code = read_machine_code()\ndays = input('请输入授权天数：')    # 0 表示永久\na_user_code = gen_user_code(days, my_crypt)\na_register_code = gen_register_code(\n    a_machine_code, a_user_code, my_crypt\n)\n```\n\n\u003e 实际使用时可在本仓库中执行 [`python gen_register_code.py`](./gen_register_code.py) 为用户生成【用户码】和【注册码】\n\n\n### 场景步骤四（用户本地）\n\n1. 用户运行应用主程序\n2. 主程序读取【用户码】文件（或让用户输入用户码）\n3. 主程序在用户本地重新生成【机器码】\n4. 主程序利用【用户码】和【机器码】生成【注册码】\n5. 主程序比对【生成的注册码】和【管理员提供的注册码】内容是否一致\n6. 若一致，且授权未过期，程序运行；否则，程序终止\n\n```python\nfrom mur.user import *\n\nu_user_code = read_user_code()\nrst = verify_authorization(u_user_code, my_crypt)\nif rst == True :\n    app.run()\nelse :\n    exit(1)\n```\n\n\n## 使用注意\n\n凡是使用了此工具的程序，在发布该程序时，建议不要直接用 `Pyinstaller` 打包成 `*.pyc`，然后供用户使用，否则很容易被反编译破解。\n\n建议先对源码做加密处理，再提供给用户使用。有两个方法，任选一个即可：\n\n### Cython 编译为动态链接\n\n1. 先使用 `Cython` 生成 `*.py` 的动态连接 `*.pyd` 文件\n2. 再使用 `Pyinstaller` 打包，才供用户使用。\n\n\u003e 可参考文档《[Cython + Pyinstaller 防止反编译打包](https://www.jianshu.com/p/4a0be62ee3e2?share_token=64cb40ef-ad3b-4f2e-abd6-3bf95af210b6)》\n\n\n### Pyinstaller 加密\n\n1. 先用 pip 命令安装 `tinyaes` 和 `pycrypto` （需要提前安装 Microsoft Visual Studio 和设置环境变量 CL）\n2. 使用 `Pyinstaller` 打包时增加 `--key ${password}` （此时编译的中间文件为 `*.pyc.encrypted`）。\n\n可参考文档：\n\n- 《[Pyinstaller 打包的 exe 之一键反编译 py 脚本与防反编译](https://blog.csdn.net/as604049322/article/details/119834495?share_token=a97db520-65be-4a54-b9cf-0a452163fb9d)》\n- 《[谈谈 Pyinstaller 的编译和反编译，如何保护你的代码](https://chengxuyuanwenku.tumblr.com/post/611434747121549312/%E8%B0%88%E8%B0%88-pyinstaller-%E7%9A%84%E7%BC%96%E8%AF%91%E5%92%8C%E5%8F%8D%E7%BC%96%E8%AF%91%E5%A6%82%E4%BD%95%E4%BF%9D%E6%8A%A4%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81)》\n- 《[Microsoft Windows Python-3.6 PyCrypto installation error](https://stackoverflow.com/questions/41843266/microsoft-windows-python-3-6-pycrypto-installation-error/46921479#46921479)》\n\n\n","funding_links":["https://ko-fi.com/exppoc","https://lyy289065406.github.io/sponsor/"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fpy-gen-mur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexp-codes%2Fpy-gen-mur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fpy-gen-mur/lists"}