Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Gocrypt is a lightweight, command-line encryption utility that provides secure file encryption and decryption using AES-128 and AES-256 with GCM mode.

License

Notifications You must be signed in to change notification settings

sgaunet/gocrypt

Repository files navigation

Go Report Card GitHub release GitHub Downloads Coverage Badge linter coverage Snapshot Build Release Build GoDoc License

Gocrypt

gocrypt is a simple and efficient command line tool to encrypt and decrypt files using AES-128 or AES-256 encryption.

Features

  • Encrypt and decrypt files using AES-128 or AES-256 (GCM mode)
  • Key can be provided via a file or the GOCRYPT_KEY environment variable
  • Easy integration in scripts and automation
  • Cross-platform: works on Linux, macOS, and Windows

Version Compatibility

⚠️ Important Breaking Change ⚠️

Version 2 (v2) introduced AES GCM (Galois/Counter Mode) encryption, which breaks compatibility with files encrypted using version 1 (v1).

  • Files encrypted with v1 cannot be decrypted with v2
  • Files encrypted with v2 cannot be decrypted with v1

This incompatibility is due to the fundamental change in the encryption mode from v1 to v2. AES GCM provides better security with authenticated encryption but requires a different format that is not backwards compatible.

Usage

$ gocrypt help
Tool to encrypt/decrypt files using AES128 or AES256.

Usage:
  gocrypt [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  dec         decrypt file in AES 128/256
  enc         encrypt file in AES 128/256
  help        Help about any command
  version     print version of gocrypt

Flags:
  -h, --help   help for gocrypt

Use "gocrypt [command] --help" for more information about a command.

Example

# Encrypt a file with a 32-byte key (AES-256)
gocrypt enc --i input.txt --o encrypted.bin --k keyfile.txt

# Decrypt a file
gocrypt dec --i encrypted.bin --o decrypted.txt --k keyfile.txt

Key Format

  • For AES-128, the key must be exactly 16 bytes (characters)
  • For AES-256, the key must be exactly 32 bytes (characters)
  • The key can be provided in a file or via the GOCRYPT_KEY environment variable

Demo

Demo

Recommendation

Even though this tool is maintained, for most use-cases you should consider using age which is a more modern and secure encryption tool.

Install

Download the binary from the releases section. There is no official Docker image, but you can add the binary to your own Docker image if needed.

With Homebrew

brew tap sgaunet/homebrew-tools
brew install sgaunet/tools/gocrypt

Use in Docker

FROM sgaunet/gocrypt:latest as gocrypt

FROM alpine:latest
COPY --from=gocrypt /gocrypt /usr/local/bin/gocrypt
...

Tests

The project includes automated tests for both small and large files. See the tests/ directory for details.

task tests

License

MIT License

About

Gocrypt is a lightweight, command-line encryption utility that provides secure file encryption and decryption using AES-128 and AES-256 with GCM mode.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 2

  •  
  •