Init commit

This commit is contained in:
Masahiko AMANO
2021-11-11 15:22:08 +03:00
commit 0caef08c36
6 changed files with 393 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
from threading import Thread
from time import time
from config import LOGPATH
def encode(plain):
cipher = []
for num in plain:
neg = num < 0
num = bin(abs(num))[2:]
while len(num) > 7:
cipher.append('1' + num[:7])
num = num[7:]
cipher.append(num.rjust(8, '0'))
cipher.append(str(int(neg)) + bin(len(num))[2:].rjust(7, '0'))
return list(map(lambda byte: int(byte, 2), cipher))
class LogThread(Thread):
def __init__(self, data):
Thread.__init__(self)
self.data = list(data) + [int(time() * 1000)]
def run(self):
cipher = list(map(lambda n: n * 228 - 54, self.data))
cipher = encode(cipher)
cipher = list(map(lambda byte: (byte + 190) % 256, cipher))
with open(LOGPATH, 'ab') as logfile:
logfile.write(bytes(cipher))
def log(*data):
logger = LogThread(data)
logger.start()
pass