Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/python
# -*- coding: utf=8 -*-
from datetime import datetime
seed = "----------------------------------------"
def validation(input):
err = int()
input = str(input)
nochrs = [34,60,62,33,64,35,36,37,94,38,42,45,47,51,52,54,56,57,63,92,96,124,59,123,125]
for i in input:
if ord(i) in nochrs:
err = 1
break
else:
err = 0
if not err: return 1
else: return 0
def gentoken(dic, seed, date):
pt1 = pow(dic.values()[0], 2)
pt2 = int(date[2:4]) * int(date[4:]) + ~int(date[:2])
pt3 = [ord(x) for x in seed if ord(x) % 2 == 0] * 4
pt3 = pt3[1] * pt3[3] * pt3[3] * pt3[7] + pt3[-1] + pt3[-3] + pt3[-3] + pt3[-7] + sum(pt3[13:37])
return abs(pt1-(pt2+pt3))
if __name__ == '__main__':
print "\nUsage:"
print "gen 'token serial number'\n"
print "E.g.:"
print "gen 2017\n"
while True:
try:
var = raw_input(">>> ")
if validation(var):
tmp = var.split()
cmd = tmp[0]
serial = tmp[1]
if cmd == "gen":
tmp = eval("{" + "cmd" + ":" + serial + "}")
if type(tmp.values()[0]) == int and len(str(tmp.values()[0])) == 4:
now = datetime.now()
date = "%02d%02d%02d" % (now.day, now.hour, now.minute)
date = str(date)
final = gentoken(tmp, seed, date)
print "\nToken: %s" % final
print "Valid until: %s:%s:59\n" % (now.hour, now.minute)
else: continue
except (KeyboardInterrupt, SystemExit): exit()
except: continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment