Guest User

challenge3

a guest
May 12th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. #Thanks for your awesome streams, they are very informativ and good understandeble(Im 15). Pls keep it up.
  2.  
  3.  
  4.  
  5. msg_encode = "10101011101000110100011101111111011111110111010010110010011100101111001011001001101110011010001110111111101001011110100111011110110010110010011101010111101100111110101111101111011110111101110111111100101100100101100100111011001110010110010011010001110110011110110100101100100110111001110010111"
  6.  
  7.  
  8. tree =  {
  9.     "1" : '1',
  10.     "2" : '01',
  11.     "3" : '001',
  12.     "0" : '000'
  13. }
  14.  
  15. #mog = ["0", "10", "110" , "111"]
  16. #mog = ["1", "01", "001", "000"]
  17. mog = ["0", "11", "101", "100"]
  18. #mog = ["1", "00", "010", "011"]
  19.  
  20. def encode_to_q(tree):
  21.     l = ""
  22.     global msg_encode
  23.     en = ""
  24.     p = 0;
  25.     z = 0
  26.     for i in range(0, len(msg_encode) + 1):
  27.         if tree["1"] == msg_encode[p:i]:
  28.             en += "1"
  29.             p = i
  30.         if tree["2"] == msg_encode[p:i]:
  31.             en += "2"
  32.             p = i
  33.         if tree["3"] == msg_encode[p:i]:
  34.             en += "3"
  35.             p = i
  36.         if tree["0"] == msg_encode[p:i]:
  37.             en += "0"
  38.             p = i
  39.  
  40.  
  41.     print en
  42.    
  43.     s = 0
  44.     for i in range(len(en) - 1, -1, -1):
  45.         z += pow(4, s) * int(en[i])
  46.         s += 1
  47.  
  48.     p = str(hex(z))
  49.     p = p.replace("0x", "")
  50.     p = p.replace("L", "")
  51.     try:
  52.  
  53.         print p.decode("hex")[::-1]
  54.     except:
  55.         pass
  56.     return
  57.  
  58.  
  59. def all_perms():
  60.     lc = 0
  61.     global tree
  62.     global mog
  63.     for p in range(4):
  64.         for o in range(4):
  65.             for l in range(4):
  66.                 for g in range(4):
  67.                     if (p != o and l != g and l != p and g != p and g != p and p != l and o != l and o != g):
  68.                         tree["1"] = mog[p]
  69.                         tree["2"] = mog[o]
  70.                         tree["3"] = mog[l]
  71.                         tree["0"] = mog[g]
  72.  
  73.  
  74.                         encode_to_q(tree)
  75.  
  76.    
  77.  
  78.  
  79.  
  80.  
  81. all_perms()
Advertisement
Add Comment
Please, Sign In to add comment