mirror of
https://github.com/antonioCoco/SharPyShell
synced 2026-06-08 13:11:44 +00:00
9e0ceb7540
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.
17 lines
488 B
Python
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()
|