Wing IDE 6.x 算号器注册机代码

  1. .py为Python文件,可以直接在pythonIDE中编辑运行;

  2. 在cmd中运行.py文件命令 Python FilePath\FileName.py;

  3. Python2.x与Python3.x版本不同有部分语句不同,所以需要使用对应版本的Python运行对应版本文件。

python 2.x 版本的代码

import string
import random
import sha

BASE16 = '0123456789ABCDEF'
BASE30 = '123456789ABCDEFGHJKLMNPQRTVWXY'


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 = long(0)
    for digit in str(number):
        x = x * len(fromdigits) + fromdigits.index(digit)

    res = ''
    while x > 0:
        digit = x % len(todigits)
        res = todigits[digit] + res
        x /= len(todigits)

    if neg:
        res = '-' + res
    return res


def AddHyphens(code):
    return code[:5] + '-' + code[5:10] + '-' + code[10:15] + '-' + code[15:]


def 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 result


def loop(ecx, lichash):
    part = 0
    for c in lichash:
        part = ecx * part + ord(c) & 1048575
    return part

rng = AddHyphens('CN' + randomstring(18, '123456789ABCDEFGHJKLMNPQRTVWXY'))
print 'License id: ' + rng
act30 = raw_input('Enter request code:')
lichash = act30
hasher = sha.new()
hasher.update(act30)
hasher.update(rng)
lichash = AddHyphens(lichash[:3] + SHAToBase30(hasher.hexdigest().upper()))
part5 = format(loop(23, lichash), '05x') + format(loop(161, lichash), '05x') + format(loop(47, lichash),
                                                                                      '05x') + format(loop(9, lichash),
                                                                                                      '05x')
part5 = BaseConvert(part5.upper(), BASE16, BASE30)
while len(part5) < 17:
    part5 = '1' + part5

part5 = 'AXX' + part5
print 'Activation code: ' + AddHyphens(part5)

Python 3.x 版本的代码

import string
import random
import hashlib

BASE16 = '0123456789ABCDEF'
BASE30 = '123456789ABCDEFGHJKLMNPQRTVWXY'


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 = 0
    for digit in str(number):
        x = x * len(fromdigits) + fromdigits.index(digit)

    res = ''
    while x > 0:
        digit = x % len(todigits)
        res = todigits[digit] + res
        x //= len(todigits)

    if neg:
        res = '-' + res
    return res


def AddHyphens(code):
    return code[:5] + '-' + code[5:10] + '-' + code[10:15] + '-' + code[15:]


def 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 result


def loop(ecx, lichash):
    part = 0
    for c in lichash:
        part = ecx * part + ord(c) & 1048575
    return part

rng = AddHyphens('CN' + randomstring(18, '123456789ABCDEFGHJKLMNPQRTVWXY'))
print('License id: {}'.format(rng))
act30 = input('Enter request code:')
lichash = act30
hasher = hashlib.sha1()
act30 = act30.encode()
hasher.update(act30)
rng = rng.encode()
hasher.update(rng)
lichash = AddHyphens(lichash[:3] + SHAToBase30(hasher.hexdigest().upper()))
part5 = format(loop(23, lichash), '05x') + format(loop(161, lichash), '05x') + format(loop(47, lichash),
                                                                                      '05x') + format(loop(9, lichash),
                                                                                                      '05x')
part5 = BaseConvert(part5.upper(), BASE16, BASE30)
while len(part5) < 17:
    part5 = '1' + part5

part5 = 'AXX' + part5
print('Activation code: {}'.format(AddHyphens(part5)))

benben

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值