rand_char_set = 'L23456789ABCDEFGHJKMNPQRSTUVWXYZ' def rand_string(size=22, chars=rand_char_set): return ''.join((random.choice(chars) for _ in range(size)))
def calc_char(input_str:str, chars=rand_char_set): return chars[sum((chars.index(c) for c in input_str)) % len(chars)]
def key_gen(): ''' get random 22chars from char set and do final two chars calc: algo: divide @serial into two set ,get char pos in @rand_char_set, do add and get the index of new char in @rand_char_set 1, {0, 2, 4, 6, 8, 10, 12, 14} 2, {1, 3, 5, 7, 9, 11, 13, 15}''' serial = rand_string(size=22) return serial + calc_char(serial[0:16:2]) + calc_char(serial[1:16:2])