import hashlib
import random
def m4(string_7):
text2 = ""
text3 = ""
text2 += string_7[10:12] + string_7[0:2] + string_7[14:16]
text2 += string_7[21:23] + string_7[6:8] + string_7[4:6]
print(text2)
for num in range(1,13):
charAtIndex = text2[num-1]
if charAtIndex.isdigit():
numValue = int(charAtIndex)
text3 += str(numValue ^ 5)
else:
text4 = chr(ord(charAtIndex) + 20 - num)
if text4 == "O":
text3 += "0"
else:
text3 += text4
text3 = text3.replace("0", "7")
result = text3[8:10] + text3[4:6] + text3[10:12] + text3[6:8]
return result
def m12(string_7):
length = len(string_7)
num = 0
if length > 0:
for i in range(length):
num3 = ord(string_7[i])
num4 = num3 + 7
num5 = num3 * 5
num += smethod_8(num3, num4, num5)
num += smethod_9(num3, num4, num5)
num += smethod_10(num3, num4, num5)
num *= smethod_11(num3, num4, num5) + 12
if num > 100000000:
num = int(str(num)[max(0,len(str(num))-7):])
text = str(num)
if len(text) >= 6:
return text[len(text)-6:]
else:
return str(num + 523109)[max(0, len(str(num+523109))-6):]
else:
return ""
def smethod_8(int_0, int_1, int_2):
return (int_0 << 2) | (int_1 & int_2)
def smethod_9(int_0, int_1, int_2):
return int_0 & int_2 & ((int_1 << 3) | int_2)
def smethod_10(int_0, int_1, int_2):
return (int_0 & (int_2 << 2)) | ((int_1 << 3) & int_2)
def smethod_11(int_0, int_1, int_2):
return (int_0 << 4) & (int_2 << 2) & ((int_1 << 2) | int_2)
def string_to_md5(string):
return hashlib.md5(string.encode('utf8')).hexdigest().upper()
def main(pcCode, regDate="20291228"):
text = pcCode.replace("-", "")
if len(text) > 10:
text = text[0:10] + text[len(text)-5:]
regCode = m4(string_to_md5(m12(text)))
year3 = ["8", "9", "C"]
year41 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
year42 = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "K"]
month10 = ["4", "5", "A"]
month11 = ["6", "7", "B"]
i = random.randint(0,2)
y3 = regDate[2]
y4 = regDate[3]
m1 = regDate[4]
m2 = regDate[5]
d1 = regDate[6]
d2 = regDate[7]
month = month10[:] if m1=="0" else month11[:]
zccode = regCode[0:4]
zccode += year3[i]
zccode += year42[year41.index(y4)]
zccode += month[i]
zccode += year42[year41.index(m2)]
zccode += regCode[4:8]
zccode += year42[year41.index(d1)]
zccode += d2 + "2"
return zccode
if __name__ == "__main__":
regDate = "20291228"
while True:
pcCode = input("输入机器码:")
if not pcCode or pcCode.lower() in ["q","e","quit","exit"]:
break
print(f" 注册码:{main(pcCode)}")