This project provides a robust implementation of file encryption and decryption using AES-GCM in Go.
- AES (Advanced Encryption Standard) with GCM mode
- Secure key handling
- File-based encryption/decryption
- Command-line interface
- Makefile support
- Go 1.21 or later
- Key size: 16 bytes (AES-128)
- Modern, secure block cipher
- Uses GCM mode for authenticated encryption
- Recommended for secure data encryption
-
Clone the repository:
git clone https://github.com/yourusername/go-encrypt cd go-encrypt/
-
Build the program:
make build
-
Encrypt a file:
make encrypt
-
Decrypt a file:
make decrypt
The program supports the following flags:
-key string 16-byte encryption/decryption key
-input string input file path
-encrypt string output path for encrypted file
-decrypt string output path for decrypted file
-
Direct command line usage:
./go-encrypt -key "1234567890123456" -input "example.txt" -encrypt "encrypted.bin" ./go-encrypt -key "1234567890123456" -input "encrypted.bin" -decrypt "decrypted.txt"
-
Using Makefile (with default values):
make encrypt # Uses KEY=1234567890123456 and INPUT_FILE=example.csv make decrypt
- Always use strong, random keys (16 bytes for AES-128)
- Keep your keys secure and never commit them to version control
- The implementation uses AES-GCM which provides both confidentiality and authenticity
Contributions are welcome! Please feel free to submit a Pull Request.
-
Run all tests:
make test
-
Run tests with coverage:
make test-coverage
This will generate a coverage report in HTML format (coverage.html)
-
Run specific tests:
go test -v ./... -run TestName
-
Run tests for a specific package:
go test ./pkg/encryption -v
-
Run tests with race detection:
go test -race ./...
Tests are organized in the following structure:
├── pkg/
│ ├── encryption/
│ │ ├── aes_test.go
│ │ ├── des_test.go
│ │ └── rc4_test.go
│ └── utils/
│ └── utils_test.go
Each test file corresponds to its implementation file and follows Go's standard testing conventions.
The test suite includes:
- Unit tests for each encryption algorithm (AES, DES, RC4)
- Key size validation tests
- Encryption/decryption round-trip tests
- Error handling tests
When contributing new features, please ensure:
- All new code is thoroughly tested
- Tests are placed in the appropriate
_test.go
file - Test coverage is maintained or improved
- Tests are clear and well-documented