Files
  • main.py
  • serial.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import string
import random


def id_generator(size=16, chars=string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))


print("Licence Key Gen")
length = int(input("Length: "))  # Length
chs = int(input("Char/Sect: "))  # Char/Sect or Characters/Section
amount = int(input("Amount: "))  # Amount
for i in range(amount):
    ID = id_generator(size=length)
    # print(int(length / chs))
    box = int(length / chs)
    if chs > length:  # If Length < Char/Sect, Exit
        print("Length is Less than Char/Sect")
        exit()
    if length / chs == 1:  # If Length = Char/Sect, Exit
        print("Length is Equal to Char/Sect")
        exit()
    check = length % chs
    # print("CHK: ", str(check))
    if check > 0:  # If Length/Chs is not a Full Number, Exit
        print("Length is Not Divisible by Char/Sect")
        exit()
    i = 1
    lento = 1
    if lento > 0 and box != length:
        while i < length and lento > 0:
            # print("IO: ", length - (box * i))
            lento = length - (chs * i)
            i += 1
            ID = ID[:lento] + '-' + ID[lento:]
        ID = ID[1:]
        print(ID)

    if box == length:
        while i < (length + 1):
            i += 1
            leng = length - i
            ID = ID[:leng] + '-' + ID[leng:]
        ID = ID[1:]
        print(ID)
    else:
        pass

    try:
        with open('serial.txt', 'a') as f:
            f.write(ID + '\n')
    except Exception:
        try:
            with open('serial.txt', 'w') as f:
                f.write(ID + '\n')
        except Exception:
            pass