zoukankan      html  css  js  c++  java
  • Wing IDE 6.0 算号器注册机代码

    我开发Python时喜欢用Wing IDE, 然后最近发现Wing IDE升级到6.0版本了, 但是之前能在5.1上用的算号器代码不能用在6.0上了, 所以就上网搜搜是否有相关算号器, 果然, 找到了以下代码 
    首先, 这个代码我是从http://www.hnsdedu.com/kuangsir/?p=199这找到的, 感谢原作者, 可惜他上面的排版不好导致复制下来还需要修改缩进和标点符号才能使用, 所以在这里我从新整理了一下 
    另外为了满足其他人的需求,我也附上了python3版本的代码,亲测可用!

    这个是python2版本的代码

    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)

    这个是python3版本的代码

    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)))
  • 相关阅读:
    Hihocoder 1275 扫地机器人 计算几何
    CodeForces 771C Bear and Tree Jumps 树形DP
    CodeForces 778D Parquet Re-laying 构造
    CodeForces 785E Anton and Permutation 分块
    CodeForces 785D Anton and School
    CodeForces 785C Anton and Fairy Tale 二分
    Hexo Next 接入 google AdSense 广告
    如何统计 Hexo 网站的访问地区和IP
    Design and Implementation of Global Path Planning System for Unmanned Surface Vehicle among Multiple Task Points
    通过ODBC接口访问人大金仓数据库
  • 原文地址:https://www.cnblogs.com/richiewlq/p/9325738.html
Copyright © 2011-2022 走看看