Guest User

Untitled

a guest
May 10th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import itertools
  2.  
  3. enc = "10101011101000110100011101111111011111110111010010110010011100101111001011001001101110011010001110111111101001011110100111011110110010110010011101010111101100111110101111101111011110111101110111111100101100100101100100111011001110010110010011010001110110011110110100101100100110111001110010111"
  4.  
  5. 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")]]
  6.  
  7. decs = []
  8.  
  9. perms = itertools.permutations("0123")
  10.  
  11. for vocab in vocabs:
  12.   dec = ""
  13.   working_enc = enc
  14.  
  15.   while len(working_enc) > 0:
  16.     found = False
  17.     for i,v in vocab:
  18.       if working_enc.startswith(v):
  19.         working_enc = working_enc[len(v):]
  20.         dec = dec + i
  21.         found = True
  22.     if found == False:
  23.       print "Patterns don't fit at: " + working_enc
  24.   decs.append(dec)
  25.  
  26. for p in perms:
  27.   for d in decs:
  28.     d = d.replace("A", p[0])
  29.     d = d.replace("B", p[1])
  30.     d = d.replace("C", p[2])
  31.     d = d.replace("D", p[3])
  32.     try:
  33.       print hex(int(d,4))[2:-1].decode("hex")[::-1]
  34.     except TypeError:
  35.       print "Can't do that one..."
Advertisement
Add Comment
Please, Sign In to add comment