Files
antonioCoco-SharPyShell/core/ChannelXOR.py
T
NuHarborMartin 9e0ceb7540 AES128 and AES256 encryption fixes
Now using bytes for both XOR and AES encrypt methods.

Decrypt now returns str. This allows both encryption methods to use the _encrypt_request successfully without encoding issues.
2021-08-04 16:37:36 -04:00

17 lines
488 B
Python

from utils.Singleton import Singleton
from itertools import cycle
class ChannelXOR(Singleton):
password = None
def __init__(self, password):
self.password = password
def encrypt(self, plain_data):
key = self.password
xored = ''.join(chr(ord(x) ^ ord(y)) for (x, y) in list(zip(plain_data, cycle(key))))
return bytes(xored, 'utf-8')
def decrypt(self, encrypted_data):
return self.encrypt(encrypted_data.decode('utf-8')).decode()