真的很抱歉,我是一个菜鸟编码员,试图做到这一点,因此用户需要输入存储在本地计算机上的许可证密钥,并从 python 中的 keygen.sh 检查策略。
到目前为止,我有下面的代码,但我正在努力寻找任何可以帮助我的文档。我目前正在使用一个名为 keygen_licensing_tools 的库,但我无法弄清楚如何解决这个问题。
任何帮助将不胜感激
main.py
from uuid import getnode as get_mac
import requests
import json
import hashlib
import os
import sys
from keygen_licensing_tools import check_key
from list1 import type
class MainMenu:
while True:
license = check_key(
"product-name",
account_id = "",
keygen_verify_key = "",
product_id="",
# cache_path="/tmp/license-cache.json",
# optionals with default values:
# refresh_cache_period=timedelta(days=1),
# cache_age_warning=timedelta(days=3),
# cache_age_error=timedelta(days=7),
# expiry_warning=timedelta(days=7),
)
if license.is_valid:
success()
else:
print("License Invalid")
def success():
print("")
print("\n Select list:")
print("[0] - Prices")
print("[1] - Exit")
tcg = input("Select (0-1): ")
if tcg == '0':
os.system('cls')
type()
if tcg == '1':
print("")
exit()
注意: 我没有 keygen.sh 帐户,也没有 API 密钥。所以我自己不能尝试。所以我的答案相当笼统,但希望能为您指明正确的方向。
keygen_licensing_tools
' GitHub 存储库不再存在。访问存储库会导致404
页面,并且被(临时?)删除、移动或重命名(截至 2022 年 5 月 6 日)。
直接使用 API 可能会更好:
requests
来进行API调用。
这里还有一个教程如何使用
requests
访问API。
您首先必须验证自己的身份,然后才能访问所需的端点。我不确定那是哪一个,因为我无法查找
check_key
正在做什么。
编辑:您在评论中分享的链接有一个
main.py
,其中有两个API请求示例。不知道这些是不是你需要的。
我建议,首先阅读如何使用
requests
(甚至可以尝试另一个 API 来测试和理解该包),然后通过 keygen.sh 的 API 找到您需要的内容。
如果您希望使用 Python 接口来验证许可证,您可以使用 Cryptolens API 作为示例。代码类似于下面的代码:
RSAPubKey = ""
auth = ""
result = Key.activate(token=auth,\
rsa_pub_key=RSAPubKey,\
product_id=3349, \
key="ICVLD-VVSZR-ZTICT-YKGXL",\
machine_code=Helpers.GetMachineCode(v=2))
if result[0] == None or not Helpers.IsOnRightMachine(result[0], v=2):
# an error occurred or the key is invalid or it cannot be activated
# (eg. the limit of activated devices was achieved)
print("The license does not work: {0}".format(result[1]))
else:
# everything went fine if we are here!
print("The license is valid!")
SDK可以通过
pip install licensing
安装,并且没有任何依赖。源代码位于 https://github.com/Cryptolens/cryptolens-python
免责声明我是 Cryptolens 的开发人员之一。