Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- import urllib
- class Verschluesselung():
- def __init__(self):
- self.sA = ""
- self.sB = ""
- loc_1 = 2**3 * 2**3
- 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]
- 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]
- loc_4 = 0
- for loc_4 in xrange(0, len(loc_2)):
- self.sA = self.sA + chr(loc_2[loc_4] + loc_1)
- self.sB = ""
- loc_5 = 0
- for loc_5 in range(0, len(loc_3)):
- self.sB = self.sB + chr(loc_3[loc_5] + loc_1)
- print "sA: %s (%d)" % (self.sA, len(self.sA))
- print "sB: %s (%d)" % (self.sB, len(self.sB))
- # encoded: oyADYQdI2AJrD)4%26(Z1sx
- # ow9Hkkr8vkvvE438.MEdk
- # string: ct=keep_session_alive
- def encode(self, text):
- enc = ""
- loc_3 = 0
- loc_4 = 0
- for loc_4 in xrange(0, len(text)):
- if loc_3 >= len(self.sB):
- loc_3 = 0
- loc_5 = string.find(self.sA, text[loc_4])
- if loc_5 >= 0:
- loc_6 = (loc_5 + string.find(self.sA, self.sB[loc_3])) % len(self.sA)
- #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)
- enc = enc + self.sA[loc_6]
- loc_3 = loc_3 + 1
- continue
- enc = enc + text[loc_4]
- return enc
- # encoded: oyADYQdI2AJrD)4%26(Z1sx
- # ow9Hkkr8vkvvE438.MEdk
- # string: ct=keep_session_alive
- def decode(self, text):
- dec = ""
- y = 0
- for x in xrange(0, len(text)):
- if y >= len(self.sB):
- y = 0
- loc_6 = string.find(self.sA, text[x])
- if loc_6 >= 0:
- key = string.find(self.sA, self.sB[y])
- if key > loc_6:
- loc_5 = loc_6 + len(self.sA) - key
- else:
- loc_5 = loc_6 - key
- #print "e, d, 5, k, 6: %s, %s, %d, %d, %d" % (text[x], self.sA[loc_5], loc_5, key, loc_6)
- dec = dec + self.sA[loc_5]
- y = y + 1
- continue
- dec = dec + text[x]
- return dec
- if __name__ == "__main__":
- b = Verschluesselung()
- print b.encode("ct=keep_session_alive")
- print b.decode("oyADYQdI2AJrD)4&(Z1sx")
- 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