Answer the question
In order to leave comments, you need to log in
How to decrypt a string?
Somehow I forgot all the data from one of the toys and decided to dig for resources.
I dug up my data, but it's encrypted to the point of horror.
I have two lines (I won’t give the second one, because the password is there):
Here is one of them:
AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA9wj0kiicok2tyiEa+EOoigQAAAACAAAAAAAQZgAAAAEAACAAAABuAbvtG6ep6YlJqB5xEz1i8dqosmY3+PGT5VuBAry3mQAAAAAOgAAAAAIAACAAAAAJuIbwic89F3oRlzD0lnUaQtfPdHMAlS4gqMyeTLivaTAAAAD6lZnI02EKA73X7a6sYwRaocQ23noSZHYWrCdM50a5Og4+lI6mvcoBwWQEIpcXhtdAAAAA1aVZQ65Ki59rMYVKzP4GhNc9cA+xgLPfsEKlOWyX+4C2uMH+Woy+d3Abs8GlIJFGD8ND6pzbXD+pu+D8p4AggQ==
import base64
from debug_utils import LOG_CURRENT_EXCEPTION
class XORObfuscator:
__PREFIX = '#obfuscate:'
def __init__(self, key):
if len(key) < 1:
raise ValueError, 'Key length must be at least one character'
self.__key = key
def __doXor(self, data):
kIdx = 0
processed = []
for x in range(len(data)):
processed.append(chr(ord(data[x]) ^ ord(self.__key[kIdx])))
kIdx = (kIdx + 1) % len(self.__key)
return ''.join(processed)
def obfuscate(self, data):
return base64.b64encode(self.__PREFIX + self.__doXor(data))
def unobfuscate(self, data):
if len(data.strip()) % 4 != 0:
return data
try:
decode = base64.b64decode(data)
except:
LOG_CURRENT_EXCEPTION()
return data
if decode.startswith(self.__PREFIX):
return self.__doXor(decode[len(self.__PREFIX):])
return data
class PasswordObfuscator(XORObfuscator):
def __init__(self):
XORObfuscator.__init__(self, '416c34666745786b'.decode('hex'))
Answer the question
In order to leave comments, you need to log in
In this passage, as far as I understand, the source text is XORed with a key, the prefix '#obfuscate:' is added to the result, and the result is encoded in base64.
If you give '[email protected]' as input to this algorithm, the result will be:
There is an opinion that the ciphertext you provided was generated either by another algorithm, or by this algorithm with a different key. Can you provide all sources?
@throughtheether is right, plus a little more clarification. If the string were obfuscated according to this algorithm, then base64decode would return a string starting with __PREFIX, then it would be easy to pick up the key (at least part of it) by simply xing the result with a known string. However, there is no prefix in the given string. At best, this algorithm is only suitable for password strings, as the name of one of the classes hints at...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question