This repository contains two scripts designed to compress a file, generate an MD5 checksum, and create an encrypted archive that can be extracted using a self-contained extraction script. The scripts are useful for securely distributing files with built-in integrity checks.
encscript.sh: A Bash script for Linux and macOS systems.encscript.ps1: A PowerShell script for Windows systems.
encscript.sh: Designed for Linux and macOS systems withar,bzip2,openssl, andmd5sumormd5installed.encscript.ps1: Designed for Windows systems with7z(7-Zip) andCertUtilinstalled.
Both scripts perform the following tasks:
- Compress the Input File: Uses
bzip2(Linux/macOS) or7z(Windows) to compress the input file. - Generate an MD5 Checksum: Creates an MD5 checksum for the compressed file to ensure data integrity.
- Create a Temporary Archive: Combines the compressed file and its checksum into a temporary archive.
- Generate an Extraction Script: Creates a self-contained extraction script that includes the base64-encoded content of the temporary archive.
- Run the script with the file you want to compress and encrypt as an argument:
- For Linux/macOS:
./encscript.sh <path_to_file>
- For Windows:
.\encscript.ps1 <path_to_file>
- For Linux/macOS:
- The script will generate a self-contained extraction script that contains the compressed and encrypted data.
- Transfer the extraction script to the target system.
- Run the extraction script to extract the original file:
- For Linux/macOS:
./genscript.sh
- For Windows:
.\genscript.ps1
- For Linux/macOS:
- The script will extract and decompress the file, verifying its integrity in the process.
- For Linux/macOS:
./encscript.sh myfile.txt- For Windows:
.\encscript.ps1 myfile.txtThis will generate a self-contained extraction script that contains the compressed and encrypted version of myfile.txt.
- For Linux/macOS:
./genscript.sh- For Windows:
.\genscript.ps1This will extract myfile.txt from the extraction script, decompress it, and verify its integrity.
- Ensure that the target system has the necessary commands installed before running the extraction script.
- The extraction script is self-contained and can be distributed independently.
This project is licensed under the MIT License. See the LICENSE file for details.