Cross-Platform Encryption/Decryption Tool
316
A Go application that supports encryption and decryption using various algorithms like AES-256-CBC and RSA. Supports both text and file encryption/decryption across macOS, Windows, and Linux.
# Install latest version
curl -sSL https://raw.githubusercontent.com/thanhlv-com/thanhlv-encryption-decryption/main/install.sh | bash
# Install specific version
curl -sSL https://raw.githubusercontent.com/thanhlv-com/thanhlv-encryption-decryption/main/install.sh | bash -s -- v1.1.0
# Install latest version
PowerShell -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/thanhlv-com/thanhlv-encryption-decryption/main/install.ps1'))"
# Install specific version
$env:VERSION='v1.2.0'; PowerShell -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/thanhlv-com/thanhlv-encryption-decryption/main/install.ps1'))"
The automated installer will:
/usr/local/bin (Linux/macOS) or Program Files (Windows)# Clone the repository
git clone <repository-url>
cd thanhlv-encryption-decryption
# Build for current platform
make build
# build-all for all platforms
make build-all
Download the appropriate binary for your platform from the GitHub releases page.
Generate encryption keys for different algorithms:
# Generate AES-256-CBC key (outputs base64)
./thanhlv-ed keygen -a aes-256-cbc -b
# Generate RSA key pair
./thanhlv-ed keygen -a rsa -b
# Encrypt text with key flag
./thanhlv-ed encrypt -a aes-256-cbc -k "<base64-text-key>" -t "Hello World!"
# Encrypt text with environment variable
export ENCRYPTION_KEY="<base64-text-key>"
./thanhlv-ed encrypt -a aes-256-cbc -e ENCRYPTION_KEY -t "Hello World!"
# Decrypt text with key flag
./thanhlv-ed decrypt -a aes-256-cbc -k "<base64-text-key>" -t "<base64-encrypted-text>"
# Decrypt text with environment variable
export ENCRYPTION_KEY="<base64-text-key>"
./thanhlv-ed decrypt -a aes-256-cbc -e ENCRYPTION_KEY -t "<base64-encrypted-text>"
# Encrypt text
./thanhlv-ed encrypt -a aes-256-cbc -k "MTIzZGY=" -t "Hello World!"
# Decrypt text
./thanhlv-ed decrypt -a aes-256-cbc -k "MTIzZGY=" -t "<base64-encrypted-text>"
# Encrypt with public key (key flag)
./thanhlv-ed encrypt -a rsa -k "<base64-public-key>" -t "Hello RSA World!"
# Encrypt with public key (environment variable)
export RSA_PUBLIC_KEY="<base64-public-key>"
./thanhlv-ed encrypt -a rsa -e RSA_PUBLIC_KEY -t "Hello RSA World!"
# Decrypt with private key (key flag)
./thanhlv-ed decrypt -a rsa -k "<base64-private-key>" -t "<base64-encrypted-text>"
# Decrypt with private key (environment variable)
export RSA_PRIVATE_KEY="<base64-private-key>"
./thanhlv-ed decrypt -a rsa -e RSA_PRIVATE_KEY -t "<base64-encrypted-text>"
# Encrypt file with key flag
./thanhlv-ed encrypt -a aes-256-cbc -k "MTIzZGY=" -f input.txt
# Encrypt file with environment variable
export ENCRYPTION_KEY="MTIzZGY="
./thanhlv-ed encrypt -a aes-256-cbc -e ENCRYPTION_KEY -f input.txt
# Decrypt file with key flag
./thanhlv-ed decrypt -a aes-256-cbc -k "MTIzZGY=" -f input.txt.encrypted
# Decrypt file with environment variable
export ENCRYPTION_KEY="MTIzZGY="
./thanhlv-ed decrypt -a aes-256-cbc -e ENCRYPTION_KEY -f input.txt.encrypted
# Encrypt file with public key (key flag)
./thanhlv-ed encrypt -a rsa -k "<base64-public-key>" -f document.pdf
# Encrypt file with public key (environment variable)
export RSA_PUBLIC_KEY="<base64-public-key>"
./thanhlv-ed encrypt -a rsa -e RSA_PUBLIC_KEY -f document.pdf
# Decrypt file with private key (key flag)
./thanhlv-ed decrypt -a rsa -k "<base64-private-key>" -f document.pdf.encrypted
# Decrypt file with private key (environment variable)
export RSA_PRIVATE_KEY="<base64-private-key>"
./thanhlv-ed decrypt -a rsa -e RSA_PRIVATE_KEY -f document.pdf.encrypted
-a, --algorithm: Encryption algorithm (aes-256-cbc, rsa)-k, --key: Encryption/decryption key (base64 encoded)-e, --key-env: Environment variable name containing the key (base64 encoded)-t, --text: Text to encrypt/decrypt-f, --file: File to encrypt/decrypt-o, --output: Output file (optional)Note: Either --key or --key-env must be specified (but not both).
-b, --base64: Output key in base64 format-p, --private: Private key output file (RSA only)-u, --public: Public key output file (RSA only)The application accepts base64-encoded keys. For example, if you have the string 123df, encode it to base64:
echo -n "123df" | base64
# Output: MTIzZGY=
Use MTIzZGY= as your key parameter.
RSA keys are generated in PEM format and can be used directly in base64 encoded form:
# Generate RSA keys
./thanhlv-ed keygen -a rsa -b
# This outputs both private and public keys in base64 format
# 1. Generate a key
./thanhlv-ed keygen -a aes-256-cbc -b
# Output: Generated AES-256-CBC key (base64): <your-key>
# 2. Encrypt text using key flag
./thanhlv-ed encrypt -a aes-256-cbc -k "MTExZHZzZHZzeGN2eGN2" -t "Secret message"
# Output: Encrypted text (base64): <encrypted-data>
# 2. Alternative: Encrypt text using environment variable
export MY_AES_KEY="MTExZHZzZHZzeGN2eGN2"
./thanhlv-ed encrypt -a aes-256-cbc -e MY_AES_KEY -t "Secret message"
# Output: Encrypted text (base64): <encrypted-data>
# 3. Decrypt text using key flag
./thanhlv-ed decrypt -a aes-256-cbc -k "MTExZHZzZHZzeGN2eGN2" -t "J+FWPLdwO+N6BSaRo2o8vCUImk50kHYi4SkHrzeLP9Q="
# Output: Decrypted text: Secret message
# 3. Alternative: Decrypt text using environment variable
export MY_AES_KEY="MTExZHZzZHZzeGN2eGN2"
./thanhlv-ed decrypt -a aes-256-cbc -e MY_AES_KEY -t "J+FWPLdwO+N6BSaRo2o8vCUImk50kHYi4SkHrzeLP9Q="
# Output: Decrypted text: Secret message
# 1. Generate RSA key pair
./thanhlv-ed keygen -a rsa -b
# Outputs private and public keys in base64
# 2. Encrypt with public key
./thanhlv-ed encrypt -a rsa -k "<public-key-base64>" -t "Confidential data"
# 3. Decrypt with private key
./thanhlv-ed decrypt -a rsa -k "<private-key-base64>" -t "<encrypted-data>"
# Install dependencies
make deps
# Build for development
make dev
# Run tests
make test
# Clean build artifacts
make clean
CryptoProvider interface in pkg/crypto/pkg/crypto/init.goContent type
Image
Digest
sha256:f0cc8a93f…
Size
5.6 MB
Last updated
3 months ago
docker pull thanhlvcom/thanhlv-ed