dice/dice.py

63 wiersze
137 KiB
Python

2021-06-05 18:27:57 +00:00
import sys, hashlib, getpass
d = {'11111': '-', '11112': '--', '11113': '---', '11114': ';', '11115': ':', '11116': ':-(', '11121': ':-)', '11122': ':(', '11123': ':)', '11124': '!', '11125': '!!', '11126': '!!!', '11131': '?', '11132': '??', '11133': '???', '11134': '""""', '11135': '(', '11136': '()', '11141': ')', '11142': '@', '11143': '$', '11144': '$$', '11145': '$$$', '11146': '*', '11151': '**', '11152': '***', '11153': '&', '11154': '#', '11155': '##', '11156': '###', '11161': '%', '11162': '%%', '11163': '%%%', '11164': '+', '11165': '++', '11166': '+++', '11211': '=', '11212': '==', '11213': '===', '11214': '0', '11215': '1', '11216': '10', '11221': '100', '11222': '1000', '11223': '101', '11224': '11', '11225': '111', '11226': '1111', '11231': '12', '11232': '123', '11233': '1234', '11234': '13', '11235': '14', '11236': '1492', '11241': '15', '11242': '1500', '11243': '16', '11244': '1600', '11245': '17', '11246': '1700', '11251': '18', '11252': '1800', '11253': '19', '11254': '1900', '11255': '1910', '11256': '1920', '11261': '1925', '11262': '1930', '11263': '1935', '11264': '1940', '11265': '1945', '11266': '1950', '11311': '1955', '11312': '1960', '11313': '1965', '11314': '1970', '11315': '1975', '11316': '1980', '11321': '1985', '11322': '1990', '11323': '1991', '11324': '1992', '11325': '1993', '11326': '1994', '11331': '1995', '11332': '1996', '11333': '1997', '11334': '1998', '11335': '1999', '11336': '2', '11341': '20', '11342': '200', '11343': '2000', '11344': '2001', '11345': '2002', '11346': '2003', '11351': '2004', '11352': '2005', '11353': '2006', '11354': '2007', '11355': '2008', '11356': '2009', '11361': '2010', '11362': '2015', '11363': '2020', '11364': '2030', '11365': '2035', '11366': '2040', '11411': '2045', '11412': '2050', '11413': '21', '11414': '22', '11415': '222', '11416': '2222', '11421': '23', '11422': '234', '11423': '2345', '11424': '24', '11425': '2468', '11426': '25', '11431': '26', '11432': '27', '11433': '28', '11434': '29', '11435': '3', '11436': '30', '11441': '300', '11442': '3000', '11443': '31', '11444': '32', '11445': '33', '11446': '333', '11451': '3333', '11452': '34', '11453': '345', '11454': '3456', '11455': '35', '11456': '36', '11461': '37', '11462': '38', '11463': '39', '11464': '4', '11465': '40', '11466': '400', '11511': '4000', '11512': '41', '11513': '42', '11514': '43', '11515': '4321', '11516': '44', '11521': '444', '11522': '4444', '11523': '45', '11524': '456', '11525': '4567', '11526': '46', '11531': '47', '11532': '48', '11533': '49', '11534': '5', '11535': '50', '11536': '500', '11541': '5000', '11542': '51', '11543': '52', '11544': '53', '11545': '54', '11546': '55', '11551': '555', '11552': '5555', '11553': '56', '11554': '567', '11555': '5678', '11556': '57', '11561': '58', '11562': '59', '11563': '6', '11564': '60', '11565': '600', '11566': '6000', '11611': '61', '11612': '62', '11613': '63', '11614': '64', '11615': '65', '11616': '66', '11621': '666', '11622': '6666', '11623': '67', '11624': '678', '11625': '6789', '11626': '68', '11631': '69', '11632': '7', '11633': '70', '11634': '700', '11635': '7000', '11636': '71', '11641': '72', '11642': '73', '11643': '74', '11644': '75', '11645': '76', '11646': '77', '11651': '777', '11652': '7777', '11653': '78', '11654': '789', '11655': '79', '11656': '8', '11661': '80', '11662': '800', '11663': '8000', '11664': '81', '11665': '82', '11666': '83', '12111': '84', '12112': '85', '12113': '86', '12114': '87', '12115': '88', '12116': '888', '12121': '8888', '12122': '89', '12123': '9', '12124': '90', '12125': '900', '12126': '9000', '12131': '91', '12132': '92', '12133': '93', '12134': '94', '12135': '95', '12136': '96', '12141': '97', '12142': '98', '12143': '9876', '12144': '99', '12145': '999', '12146': '9999', '12151': 'a', '12152': 'aa', '12153': 'aaa', '12154': 'aaaa', '12155': 'ab', '12156': 'abak', '12161': 'abaka', '12162': 'abakan', '12163': 'abakus', '12164': 'abc', '12165': 'abcug', '12166': 'abl', '12211': 'abo', '12212': 'abort', '12213': 'abp', '12214': 'abpa', '12215': 'abpi', '12216': 'abrys', '12221': 'absces', '1222
key1 = ""
key2 = ""
def calc_mod(dig, idx):
mod = 6
return (dig[idx] % mod) + 1
def calc_mod_var(dig, idx):
if idx < 3:
mod = 1
else:
if idx < 4:
mod = 2
else:
mod = 6
return (dig[idx] % mod) + 1
def calc_hash(key1,key2):
hash = hashlib.sha256()
hash.update(key1.encode('utf-8'))
hash.update(key2.encode('utf-8'))
# print( key1, key2 )
# print( hash.hexdigest() )
s = ''
l = ''
w = ''
for x in range(0,hash.digest_size):
y = calc_mod(hash.digest(), x)
s = s + format(y, 'd')
l = l + format(y, 'd')
if (x + 1) % 5 == 0:
s = s + ' '
w = w + d[l] + ' '
l = ''
# print( s )
print( w )
2021-06-05 18:40:24 +00:00
2021-06-05 18:27:57 +00:00
if len(sys.argv) > 1:
key1 = sys.argv[1]
if len(sys.argv) > 2:
key2 = sys.argv[2]
calc_hash(key1, key2)
else:
while True:
passwd = input("any->hidden: ")
if len(passwd) == 0 :
key1 = input("Key1: ")
key2 = input("Key2: ")
else:
key1 = getpass.getpass(prompt='Key1: ', stream=None)
key2 = getpass.getpass(prompt='Key2: ', stream=None)
if len(key1) > 0 or len(key2) > 0:
calc_hash(key1, key2)
else:
2021-06-05 18:40:24 +00:00
break;