python3 编写 WingPro7 注册机算法,,wingpro是一款
python3 编写 WingPro7 注册机算法,,wingpro是一款
wingpro是一款非常优秀的适用于python开发IDE软件
而且该软件的插件同样可以使用python语言编写,wingpro可以工作在Mac,Windows,Linux上
为此我使用python3写了个序列生成器,仅供学习算法使用
import randomimport stringimport hashlibBASE16 = ‘0123456789ABCDEF‘BASE30 = ‘123456789ABCDEFGHJKLMNPQRTVWXY‘def AddHyphens(code): return code[:5] + ‘-‘ + code[5:10] + ‘-‘ + code[10:15] + ‘-‘ + code[15:]def randomstring(size=20, chars=string.ascii_uppercase + string.digits): return (‘‘).join((random.choice(chars) for _ in range(size)))def BaseConvert(number, fromdigits, todigits, ignore_negative=True): if not ignore_negative and str(number)[0] == ‘-‘: number = str(number)[1:] neg = 1 else: neg = 0 x = int(0) for digit in str(number): x = x * len(fromdigits) + fromdigits.index(digit) res = ‘‘ while x > 0: digit = int(x % len(todigits)) res = todigits[digit] + res x //= len(todigits) if neg: res = ‘-‘ + res return resdef SHAToBase30(digest): tdigest = (‘‘).join([c for i, c in enumerate(digest) if i // 2 * 2 == i]) result = BaseConvert(tdigest, BASE16, BASE30) while len(result) < 17: result = ‘1‘ + result return resultdef loop(ecx, lichash): part = 0 for c in lichash: part = ecx * part + ord(c) & 1048575 return partdef getLicenseId() -> str: licenseId = AddHyphens(‘CN‘ + randomstring(18, ‘123456789ABCDEFGHJKLMNPQRTVWXY‘)) return licenseIddef generateCode(licenseId: str, requestCode: str) -> str: lichash = requestCode lichash = AddHyphens(lichash[:3] + SHAToBase30(hashlib.sha1((requestCode + licenseId).encode("utf-8")).hexdigest().upper())) part5 = format(loop(221, lichash), ‘05x‘) + format(loop(13, lichash), ‘05x‘) + format(loop(93, lichash), ‘05x‘) + format(loop(27, lichash), ‘05x‘) part5 = BaseConvert(part5.upper(), BASE16, BASE30) while len(part5) < 17: part5 = ‘1‘ + part5 part5 = ‘AXX‘ + part5 return AddHyphens(part5)if __name__=="__main__": licenseId=getLicenseId() print("License Id:"+licenseId) requestCode=input("requestCode:") print("generateCode:"+generateCode(licenseId,requestCode))
python3 编写 WingPro7 注册机算法
相关内容
- python计算圆面积,, 1 #coding
- python HelloWorld 的 4 种姿势,你知道几种,,安装完 Pyth
- C#调用python脚本,,只尝试了两种调用方式
- 你真的了解python中的换行以及转义吗?,,python中的分号
- python面试不得不知道的点——GIL,,# 百度搜索:pyt
- CentOS7 安装 Python3.8后 pip 安装报错,,[[email pr
- Python基础-3 输入输出,,输入输出input输
- python基础1--基本数据类型+流程控制,,?一、基本数据类
- Linux Shell curl 和 wget 使用代理IP,,
- 爬虫小案例:多协程工作,,为提高工作效率,让多
评论关闭