Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- enc = "10101011101000110100011101111111011111110111010010110010011100101111001011001001101110011010001110111111101001011110100111011110110010110010011101010111101100111110101111101111011110111101110111111100101100100101100100111011001110010110010011010001110110011110110100101100100110111001110010111"
- vocabs = [[("A","0"),("B","11"),("C","101"),("D","100")],[("A","1"),("B","00"),("C","010"),("D","011")],[("A","1"),("B","01"),("C","001"),("D","000")],[("A","0"),("B","10"),("C","110"),("D","111")]]
- decs = []
- perms = itertools.permutations("0123")
- for vocab in vocabs:
- dec = ""
- working_enc = enc
- while len(working_enc) > 0:
- found = False
- for i,v in vocab:
- if working_enc.startswith(v):
- working_enc = working_enc[len(v):]
- dec = dec + i
- found = True
- if found == False:
- print "Patterns don't fit at: " + working_enc
- decs.append(dec)
- for p in perms:
- for d in decs:
- d = d.replace("A", p[0])
- d = d.replace("B", p[1])
- d = d.replace("C", p[2])
- d = d.replace("D", p[3])
- try:
- print hex(int(d,4))[2:-1].decode("hex")[::-1]
- except TypeError:
- print "Can't do that one..."
Advertisement
Add Comment
Please, Sign In to add comment