This project contains two scripts: CompressEncrypt.nim and DecryptDecompress.py. These scripts demonstrate how to compress and encrypt data, and then decrypt and decompress it.
This Nim script performs the following tasks:
- Converts a string to a byte sequence.
- Compresses the byte sequence using Zstandard (zstd) compression.
- Encrypts the compressed data using AES-256 in CTR mode.
- Outputs the encrypted data, the key, and the IV in base64 encoding.
- Compression: Uses the
zstd/compressmodule to compress the data. - Encryption: Uses the
nimcryptolibrary to perform AES-256 encryption in CTR mode. - Key Derivation: Uses SHA-256 to derive a 32-byte key from a given string.
This Python script performs the following tasks:
- Decodes the base64-encoded ciphertext, key, and IV.
- Decrypts the ciphertext using AES-256 in CTR mode.
- Decompresses the decrypted data using Zstandard (zstd) decompression.
- Prints the decompressed data.
- Decryption: Uses the
pycryptodomelibrary to perform AES-256 decryption in CTR mode. - Decompression: Uses the
zstandardlibrary to decompress the data.
- Run
CompressEncrypt.nimto compress and encrypt your data. The script will output the encrypted data, key, and IV. - Use the output from the Nim script as input for
DecryptDecompress.pyto decrypt and decompress the data.
Ensure you have the necessary dependencies installed for both scripts:
- Nim dependencies:
nimcrypto,zstd - Python dependencies:
pycryptodome,zstandard