import time, hashlib email = "someone@example.com" application_identifier = "COOLAP" purch_location = "COOLSW" order_number = 1 time_of_generation = time.time() user_name = "John Doe" charlist = "BCDFHJKLNPRTVWXZ" print "EMAIL:", email print "APPLICATION IDENTIFIER:", application_identifier print "ORDER NUMBER:", order_number print "TIME OF GENERATION:", time.strftime("%A, %B %d, %Y at %H:%M:%S %Z", time.localtime(time_of_generation)) print "USER'S NAME:", user_name print "PURCHASE LOCATION:", purch_location raw_serial_string = application_identifier, order_number, user_name, email, time_of_generation, purch_location raw_serial_string = str(raw_serial_string) shahash = hashlib.sha1(raw_serial_string).hexdigest() ordnumber = 0 for i in raw_serial_string: ordnumber += ord(i) ordnumber %= len(shahash) shahashcut = shahash[ordnumber:] + shahash[0:ordnumber] for i in shahashcut: ordnumber += ord(i) ordnumber %= len(shahashcut) shahashcut = shahashcut[ordnumber:] + shahashcut[0:ordnumber] shanumber = int(shahashcut, 16) shahashtwo = hashlib.sha224((raw_serial_string + str(shanumber) + shahashcut)).hexdigest() for i in shahashcut + shahash: ordnumber -= ord(i) ordnumber %= len(shahash) finalhash = (shahashtwo + shahash)[ordnumber:] + (shahashtwo+shahash)[0:ordnumber] if (float(ordnumber) / 4) == float(int(ordnumber / 4)): finalfinalhash = finalhash[:len(finalhash)/4] else: intv = abs((float(ordnumber) / 4) - float(ordnumber / 4)) if intv < 0.25: finalfinalhash = finalhash[:len(finalhash)/4] elif intv < 0.5: finalfinalhash = finalhash[len(finalhash)/4:2*(len(finalhash)/4)] elif intv < 0.75: finalfinalhash = finalhash[2*(len(finalhash)/4):3*(len(finalhash)/4)] else: finalfinalhash = finalhash[3*(len(finalhash)/4):] code = "" w = 0 for i in finalfinalhash: code += charlist[int(str(i), 16)] w += 1 if (w % 6) == 0 and w != len(finalfinalhash): code += "-" finalcode = purch_location + "-" + code + "-" + application_identifier print "LICENSE CODE:", finalcode