Files
network-security/main/ed_coding.py
T
2026-05-11 10:56:16 +03:30

29 lines
560 B
Python

import json
class EdCoding:
def __init__(self, key):
self.key = key
def ende(self, data):
"""
:param data: type just dict and string
:return:
"""
text = data
if isinstance(data, dict):
text = json.dumps(data, ensure_ascii=False)
encoded = ''.join(
chr(ord(c) ^ self.key) for c in text
)
return encoded
def read_file(self):
pass
coding = EdCoding(12)
en = coding.ende({'key': 'value'})
de = coding.ende(en)
print(en, de, sep='\n')