Guest User

Untitled

a guest
Jun 21st, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. import string
  2. import urllib
  3.  
  4. class Verschluesselung():
  5.  
  6. def __init__(self):
  7. self.sA = ""
  8. self.sB = ""
  9.  
  10. loc_1 = 2**3 * 2**3
  11. loc_2 = [22, 14, 15, 16, 33, 23, 57, 58, -3, -11, 24, 25, 26, 43, 39, 40, 41, 42, -19, -18, -20, 48, 49, -7, -16, -15, 6, 7, 8, 3, 4, 5, 34, 35, 9, 10, 50, 51, 52, 53, -24, -23, 31, 17, 18, 44, 45, 46, 47, 19, 20, 21, 54, 55, 56, -10, -9, -8, 11, 12, 13, -14, -13, -12, -26, 1, 2, 36, 37, 38]
  12. loc_3 = [40, 52, -8, 42, 43, 44, 45, -13, -16, 36, 37, 38, 39, -12, 41, 49, 50, 51, -11, -10, -9, 46, 47, 48, -7, 33, -15, -14, 34, 35, 53, 54]
  13. loc_4 = 0
  14.  
  15. for loc_4 in xrange(0, len(loc_2)):
  16. self.sA = self.sA + chr(loc_2[loc_4] + loc_1)
  17.  
  18. self.sB = ""
  19. loc_5 = 0
  20.  
  21. for loc_5 in range(0, len(loc_3)):
  22. self.sB = self.sB + chr(loc_3[loc_5] + loc_1)
  23.  
  24. print "sA: %s (%d)" % (self.sA, len(self.sA))
  25. print "sB: %s (%d)" % (self.sB, len(self.sB))
  26.  
  27. # encoded: oyADYQdI2AJrD)4%26(Z1sx
  28. # ow9Hkkr8vkvvE438.MEdk
  29. # string: ct=keep_session_alive
  30. def encode(self, text):
  31. enc = ""
  32. loc_3 = 0
  33. loc_4 = 0
  34.  
  35. for loc_4 in xrange(0, len(text)):
  36. if loc_3 >= len(self.sB):
  37. loc_3 = 0
  38.  
  39. loc_5 = string.find(self.sA, text[loc_4])
  40. if loc_5 >= 0:
  41. loc_6 = (loc_5 + string.find(self.sA, self.sB[loc_3])) % len(self.sA)
  42.  
  43. #print "e, d, 5, k, 6: %s, %s, %d, %d, %d" % (self.sA[loc_6], text[loc_4], loc_5, string.find(self.sA, self.sB[loc_3]), loc_6)
  44. enc = enc + self.sA[loc_6]
  45. loc_3 = loc_3 + 1
  46. continue
  47.  
  48. enc = enc + text[loc_4]
  49.  
  50. return enc
  51.  
  52. # encoded: oyADYQdI2AJrD)4%26(Z1sx
  53. # ow9Hkkr8vkvvE438.MEdk
  54. # string: ct=keep_session_alive
  55. def decode(self, text):
  56. dec = ""
  57. y = 0
  58. for x in xrange(0, len(text)):
  59. if y >= len(self.sB):
  60. y = 0
  61.  
  62. loc_6 = string.find(self.sA, text[x])
  63. if loc_6 >= 0:
  64. key = string.find(self.sA, self.sB[y])
  65. if key > loc_6:
  66. loc_5 = loc_6 + len(self.sA) - key
  67. else:
  68. loc_5 = loc_6 - key
  69.  
  70. #print "e, d, 5, k, 6: %s, %s, %d, %d, %d" % (text[x], self.sA[loc_5], loc_5, key, loc_6)
  71. dec = dec + self.sA[loc_5]
  72. y = y + 1
  73. continue
  74.  
  75. dec = dec + text[x]
  76.  
  77. return dec
  78.  
  79. if __name__ == "__main__":
  80. b = Verschluesselung()
  81. print b.encode("ct=keep_session_alive")
  82. print b.decode("oyADYQdI2AJrD)4&(Z1sx")
  83. print b.decode(urllib.unquote("oyAt2ZgIllgmvDX2PJlNw6Ohf%2COzmshT8xx1quq%3DNkZPM2KegIz4Y%29hxN%289f88cHEhPEjpRIyAIrD%294DpE6Nc431fOdKNfQ%2CEiI1tVVjn2rhM2wM%28kD4Yt%29DgMig8KchUNA%29bxAjQqq%2DfZ%29nM3baYt%29DgMig8Kc7oNJ4IjlsHYJztZ%28%29M7caX"))
Add Comment
Please, Sign In to add comment