XZ9-COMPRESSOR is a Bash utility designed for maximum compression and cryptographic integrity verification using XZ and SHA-256.
- Ultra compression using
xz -9e - Keeps original file intact
- Automatic SHA-256 checksum generation
- Secure verification before decompression
- Interactive menu
- Lightweight and portable
- Forensic-grade integrity control
- bash
- xz-utils
- coreutils (sha256sum)
On Ubuntu/Debian:
sudo apt install xz-utils coreutilsMake executable:
chmod +x xz9-compressor.sh
Run:
./xz9-compressor.sh
- Compresses file with maximum XZ settings
- Generates
.sha256checksum file
- Verifies integrity
- Only decompresses if hash is valid
Terminates the engine.
./xz9-compressor.sh
Selection: 1
File to compress: script.shOutput:
script.sh.xz
script.sh.xz.sha256Decompression is only allowed if:
sha256sum -c file.xz.sha256#!/usr/bin/env bash
clear
BANNER="
██╗ ██╗███████╗ █████╗ █████╗ ██████╗ ██████╗
╚██╗██╔╝╚══███╔╝ ██╔══██╗ ██╔══██╗██╔══██╗██╔════╝
╚███╔╝ ███╔╝█████╗╚██████║ ███████║██████╔╝██║
██╔██╗ ███╔╝ ╚════╝ ╚═══██║ ██╔══██║██╔══██╗██║
██╔╝ ██╗███████╗ █████╔╝ ██║ ██║██║ ██║╚██████╗
╚═╝ ╚═╝╚══════╝ ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
XZ9-COMPRESSOR v1.0
Ultra Compression & Integrity Engine
"
echo -e "\033[1;32m$BANNER\033[0m"
echo "1) Compress file + generate SHA256"
echo "2) Verify SHA256 and decompress"
echo "3) Exit"
echo
read -p "Selection: " CHOICE
echo
if [[ "$CHOICE" == "1" ]]; then
read -p "File to compress: " FILE
if [[ ! -f "$FILE" ]]; then
echo "[-] File not found."
exit 1
fi
echo "[+] XZ9 Ultra Compression Engine active..."
xz -9e -k "$FILE"
if [[ $? -ne 0 ]]; then
echo "[-] Compression error."
exit 1
fi
COMPRESSED="$FILE.xz"
echo "[+] Generating SHA256 hash..."
sha256sum "$COMPRESSED" > "$COMPRESSED.sha256"
echo
echo "[✓] Operation completed!"
echo "Archive: $COMPRESSED"
echo "Hashfile: $COMPRESSED.sha256"
elif [[ "$CHOICE" == "2" ]]; then
read -p "Compressed file (.xz): " FILE
if [[ ! -f "$FILE" ]]; then
echo "[-] File not found."
exit 1
fi
HASHFILE="$FILE.sha256"
if [[ ! -f "$HASHFILE" ]]; then
echo "[-] SHA256 file missing."
exit 1
fi
echo "[+] Verifying cryptographic integrity..."
sha256sum -c "$HASHFILE"
if [[ $? -ne 0 ]]; then
echo "[-] HASH INVALID. Access denied."
exit 1
fi
echo "[✓] HASH VERIFIED"
echo "[+] Decompressing..."
xz -dk "$FILE"
if [[ $? -ne 0 ]]; then
echo "[-] Decompression error."
exit 1
fi
echo "[✓] Decompression completed."
elif [[ "$CHOICE" == "3" ]]; then
echo "XZ9 Engine terminated."
exit 0
else
echo "Invalid command."
fi
echo
echo ">>> XZ9-COMPRESSOR OPERATION COMPLETE <<<"