This project provides a simple implementation of file encryption and decryption using the AES-GCM (Galois/Counter Mode) in Go. It demonstrates how to securely encrypt and decrypt files using a secret key.
- Go 1.16 or later
-
Clone the repository:
git clone https://github.com/theognis1002/go-encrypt cd go-encrypt/
-
Set the secret key:
Update the key variables in the
.env
file (using.env.sample
as a reference) with your 16, 24, or 32 bytes key for AES-128, AES-192, or AES-256 respectively.
The Makefile includes commands to build, encrypt, and decrypt files, as well as to clean up the build files.
-
Build the project:
make build
This command compiles the Go program into a binary named file-crypto.
-
Encrypt a file:
make encrypt
This command encrypts the file example.csv into
encrypted.csv
. You can change the input and output filenames by editing the Makefile or running the binary directly with the desired arguments. -
Decrypt a file:
make decrypt
This command decrypts the file
encrypted.csv
into decrypted.csv. -
Clean up build files:
make clean
This command removes the binary and any other build-related files.
-
To encrypt
example.csv
intoencrypted.csv
, run:make encrypt
-
To decrypt
encrypted.csv
intodecrypted.csv
, run:make decrypt