| skipped 7 lines |
8 | 8 | | self.password = password |
9 | 9 | | |
10 | 10 | | def encrypt(self, plain_data): |
11 | | - | key = self.password |
12 | | - | xored = ''.join(chr(ord(x) ^ ord(y)) for (x, y) in list(zip(plain_data, cycle(key)))) |
13 | | - | return bytes(xored, 'utf-8') |
| 11 | + | key = self.password.encode() |
| 12 | + | xored = b''.join(bytes([(x ^ y)]) for (x, y) in list(zip(plain_data, cycle(key)))) |
| 13 | + | return xored |
14 | 14 | | |
15 | 15 | | def decrypt(self, encrypted_data): |
16 | | - | return self.encrypt(encrypted_data.decode('utf-8')).decode() |
| 16 | + | return self.encrypt(encrypted_data) |
17 | 17 | | |