Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 8 additions & 5 deletions src/levels/presentation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import time

import lzma
import zstandard as zstd

from cryptography.hazmat.primitives.ciphers.aead import AESGCM

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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:
Expand Down
Loading