go-encryption-service

module
v0.0.0-...-499c1dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: GPL-3.0

README ΒΆ

Golang Encryption and Key Management Service

πŸ” Overview

This project implements a production-grade encryption and key management system written in Go. It offers:

  • AES-256 encryption and decryption of data
  • RESTful APIs for key lifecycle management
  • In-memory key storage with thread-safe operations
  • Swagger-based REST API documentation hosted on GitHub Pages
  • Unit test coverage for critical components
  • Docker support for containerized deployment

🧱 Architecture

+-------------+      POST/PUT/DELETE       +-------------------+
|             |  <----------------------> |                   |
|   Client    |                           | Golang REST API   |
|             |  ---------------------->  |                   |
+-------------+      Encrypt/Decrypt      +-------------------+
                                             |          |
                                             v          v
                                   +---------------+ +---------------+
                                   | Key Manager   | | Encryptor     |
                                   | (internal)    | | (internal)    |
                                   +---------------+ +---------------+

πŸ—‚ Project Structure

.
β”œβ”€β”€ cmd/                        # Main application entrypoint
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/                   # REST handlers and routes
β”‚   β”œβ”€β”€ encryption/            # AES encryption logic
β”‚   └── keymanager/            # Key lifecycle (create/delete/reset)
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ index.html             # Swagger UI for GitHub Pages
β”‚   └── openapi.yaml           # OpenAPI spec
β”œβ”€β”€ test/                      # Unit tests
β”œβ”€β”€ Dockerfile                 # Docker setup
β”œβ”€β”€ go.mod / go.sum            # Go module definitions

πŸ“¦ API Endpoints

Method Endpoint Description
POST /api/key Create new key
DELETE /api/key/{id} Delete key by ID
PUT /api/key/{id}/reset Reset key by ID
POST /api/encrypt Encrypt data
POST /api/decrypt Decrypt data
πŸ”„ Payload Format (Encrypt/Decrypt)
{
  "key_id": "abc123",
  "data": "Hello, World!"
}

βœ… Running the Application

Locally (with Go)
git clone https://github.com/aditya-bhuyan/go-encryption-service.git
cd go-encryption-service
go run cmd/main.go
With Docker
docker build -t go-encryption-service .
docker run -p 8080:8080 go-encryption-service

πŸ§ͺ Running Unit Tests

go test ./...

πŸ› οΈ Makefile Usage

This project includes a Makefile to streamline local development and CI integration:

Command Description
make build Build the server binary
make server Run the server locally
make client Run the Go-based API client
make test Run all unit tests
make coverage Generate test coverage report
make docker-build Build the Docker image
make docker-run Run the Docker container (port 8080)
πŸ§ͺ Test and Coverage

To run all unit tests with coverage:

make test
make coverage

You can also run manually:

go test -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
🐳 Docker Build & Deploy

To build and run the project in a container:

make docker-build
make docker-run

πŸ“š API Documentation

πŸ“œ License

This project is licensed under the GNU GPLv3 License.

πŸ‘€ Author

Aditya Pratap Bhuyan
GitHub: @aditya-bhuyan
LinkedIn: Aditya Bhuyan

Directories ΒΆ

Path Synopsis
internal
api
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL