diff --git a/pyproject.toml b/pyproject.toml index 6d9f9ec..74e1449 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ dependencies = [ "colorama", "rich", "cryptography", - "cryptolayer-module-interface @ git+https://github.com/igmunv/cryptolayer-module-interface.git" + "cryptolayer-module-interface @ git+https://github.com/igmunv/cryptolayer-module-interface.git", + "zstandard" ] [tool.setuptools.package-dir] diff --git a/src/levels/presentation.py b/src/levels/presentation.py index 8b0d401..81d9f67 100644 --- a/src/levels/presentation.py +++ b/src/levels/presentation.py @@ -1,7 +1,7 @@ import os import time -import lzma +import zstandard as zstd from cryptography.hazmat.primitives.ciphers.aead import AESGCM @@ -23,7 +23,8 @@ def send_without_encrypt(self, data): self.logger.info(f"size: {len(data)}") # сжатие - data = lzma.compress(data) + cctx = zstd.ZstdCompressor(level=22) + data = cctx.compress(data) self.LOWER_LEVEL.send(data) @@ -45,9 +46,10 @@ def rworker(self, data): return try: - data = lzma.decompress(data) + dctx = zstd.ZstdDecompressor() + data = dctx.decompress(data) except Exception as e: - self.logger.error(f"lzma decompress error: {e}") + self.logger.error(f"zstd decompress error: {e}") return self.UPPER_LEVEL.receive(data) @@ -57,7 +59,8 @@ def rworker(self, data): def sworker(self, data): # сжатие - data = lzma.compress(data) + cctx = zstd.ZstdCompressor(level=22) + data = cctx.compress(data) # шифрование if self.DO_ENCRYPT: