import string
import random
import hashlib
BASE16 = '0123456789ABCDEF'
BASE30 = '123456789ABCDEFGHJKLMNPQRTVWXY'
def randomstring(size, chars = (20, string.ascii_uppercase + string.digits)):
return None((lambda .0 = None: pass)(range(size)))
def BaseConvert(number, fromdigits, todigits, ignore_negative = (True,)):
if ignore_negative and str(number)[0] == '-':
number = str(number)[1:]
neg = 1
else:
neg = 0
x = 0
res = ''
if x > 0:
digit = x % len(todigits)
res = todigits[int(digit)] + res
x //= len(todigits)
continue
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((lambda .0: [ c for i, c in .0 if (i // 2) * 2 == i ])(enumerate(digest)))
result = BaseConvert(tdigest, BASE16, BASE30)
if len(result) < 17:
result = '1' + result
continue
return result
def loop(ecx, lichash):
part = 0
return part
rng = AddHyphens('CN' + randomstring(1, '123456789ABCDEFGHJKNPQRTVXY') + randomstring(17, '123456789ABCDEFGHJKLMNPQRTVWXY'))
print('License id: ' + rng)
act30 = input('Enter request code:')
lichash = act30.strip()
hasher = hashlib.sha1()
hasher.update(act30.strip().encode('utf-8'))
hasher.update(rng.encode('utf-8'))
lichash = AddHyphens(lichash[:3] + SHAToBase30(hasher.hexdigest().upper()))
part5 = format(loop(179, lichash), '05x') + format(loop(95, lichash), '05x') + format(loop(45, lichash), '05x') + format(loop(245, lichash), '05x')
part5 = BaseConvert(part5.upper(), BASE16, BASE30)
if len(part5) < 17:
part5 = '1' + part5
continue
part5 = 'AXX' + part5
print('Activation code: ' + AddHyphens(part5))
09-21