Skip to content

Java project with a modern Swing desktop app and a deploy-ready web API for encryption/decryption with multiple algorithms.

License

Notifications You must be signed in to change notification settings

SpencerVJones/Encryption-and-Decryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Encryption & Decryption

Repo Views

A Java project with a modern Swing desktop app and a deploy-ready web API for encryption/decryption with multiple algorithms.

Report Bug Β· Request Feature

License Contributors Forks Stargazers Issues Last Commit Repo Size Platform API Java Swing Maven JUnit Encryption

πŸ“‘ Table of Contents

Overview

Encryption-and-Decryption includes:

  • A Java Swing desktop UI for interactive demos
  • A tiny JSON web API for deployment (Render-ready)

Users can:

  • Select an algorithm
  • Generate encryption keys
  • Encrypt/decrypt text via UI or HTTP API
  • Copy output instantly
  • Toggle dark/light theme

Technologies Used

  • Java
  • Swing (Desktop GUI)
  • Java HttpServer (Web API)
  • Java Cryptography APIs (javax.crypto, java.security)
  • Maven
  • JUnit 4
  • Checkstyle

Features

  • πŸ” Encrypt/decrypt text using AES, DES, RSA, and Caesar
  • πŸŽ› Algorithm dropdown for fast switching
  • πŸ”‘ One-click key generation
  • πŸ–₯ Live web UI demo at / (interactive browser client)
  • 🌐 Tiny JSON API: /api/key, /api/encrypt, /api/decrypt
  • βš™οΈ JDK-only backend (HttpServer + Java crypto APIs)
  • πŸš€ Render deployment via render.yaml
  • πŸ“‹ Copy output button for shareable demo results
  • πŸŒ™ Dark/light theme toggle
  • βœ… Status feedback for success/error states

Demo

πŸ”— Live: https://encryption-api-4yib.onrender.com/

Project Structure

encryption-and-decryption/
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ pom.xml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ render.yaml
β”œβ”€β”€ checkstyle.xml
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml
└── src/
    β”œβ”€β”€ main/
    β”‚   └── java/
    β”‚       β”œβ”€β”€ ApiServer.java
    β”‚       β”œβ”€β”€ CryptoService.java
    β”‚       β”œβ”€β”€ JsonUtil.java
    β”‚       β”œβ”€β”€ Main.java
    β”‚       └── MyFrame.java
    └── test/
        └── java/
            β”œβ”€β”€ ButtonActionsTests.java
            β”œβ”€β”€ CryptoServiceTests.java
            β”œβ”€β”€ FunctionalityTests.java
            └── GuiRenderingTests.java

API Endpoints

  • GET / - interactive live demo UI
  • GET /health - health check
  • GET /api/info - API metadata + endpoint list
  • POST /api/key - generate algorithm-specific key material
  • POST /api/encrypt - encrypt plaintext
  • POST /api/decrypt - decrypt ciphertext

Example request payload:

{
  "algorithm": "AES",
  "text": "Hello World",
  "key": "optional-base64-key",
  "publicKey": "optional-base64-rsa-public-key",
  "privateKey": "optional-base64-rsa-private-key",
  "shift": 7
}

Quick curl flow:

# 1) Generate an AES key
curl -X POST http://localhost:8080/api/key \
  -H "Content-Type: application/json" \
  -d '{"algorithm":"AES"}'

# 2) Encrypt with AES key (replace KEY_VALUE)
curl -X POST http://localhost:8080/api/encrypt \
  -H "Content-Type: application/json" \
  -d '{"algorithm":"AES","text":"Hello API","key":"KEY_VALUE"}'

API Examples

AES round-trip:

# Generate key
curl -s -X POST http://localhost:8080/api/key \
  -H "Content-Type: application/json" \
  -d '{"algorithm":"AES"}'
# => {"success":true,"algorithm":"AES","key":"..."}

# Encrypt
curl -s -X POST http://localhost:8080/api/encrypt \
  -H "Content-Type: application/json" \
  -d '{"algorithm":"AES","text":"portfolio-ready","key":"<AES_KEY_BASE64>"}'
# => {"success":true,"algorithm":"AES","result":"<IV_BASE64>:<CIPHERTEXT_BASE64>","key":"..."}

# Decrypt
curl -s -X POST http://localhost:8080/api/decrypt \
  -H "Content-Type: application/json" \
  -d '{"algorithm":"AES","text":"<IV_BASE64>:<CIPHERTEXT_BASE64>","key":"<AES_KEY_BASE64>"}'
# => {"success":true,"algorithm":"AES","result":"portfolio-ready"}

RSA note:

  • If publicKey is omitted on /api/encrypt, the API generates a new RSA key pair and returns both keys.
  • /api/decrypt requires privateKey for RSA payloads.

Deploy to Render

This repo includes a Render Blueprint file (render.yaml).

  1. Push this project to GitHub.
  2. In Render, choose New + -> Blueprint.
  3. Select the repo and deploy.
  4. Render builds and runs from Dockerfile (runtime: docker in render.yaml).
  5. Verify deployment at:
https://<your-render-service>.onrender.com/
https://<your-render-service>.onrender.com/health

Local Docker run (optional):

docker build -t encryption-api .
docker run --rm -p 8080:10000 -e PORT=10000 encryption-api

Environment:

  • Render injects PORT; locally the API defaults to 8080.

Testing

Automated tests are included for:

  • GUI rendering
  • Button actions
  • Core encryption/decryption flows

Run tests:

mvn test

Getting Started

Prerequisites

  • JDK 21
  • Maven 3.9+
  • macOS, Linux, or Windows with Java GUI support

Installation

  1. Clone the repo:
git clone https://github.com/SpencerVJones/Encryption-and-Decryption.git
  1. Move into the project:
cd Encryption-and-Decryption
  1. Build:
mvn clean compile

Run Desktop App

Build and launch:

mvn clean compile
java -cp target/classes Main
  • Click Generate Key
  • Enter text in the input box
  • Click Encrypt or Decrypt
  • Use Copy to copy results

Run API Locally

Build a runnable jar and start the API:

mvn clean package -DskipTests
java -jar target/EncrptionProgram-1.0-SNAPSHOT.jar

Then test:

curl http://localhost:8080/api/info
curl http://localhost:8080/health

Open http://localhost:8080/ in your browser for the live UI.

Usage

Use this project for:

  • Live browser demos hosted on Render
  • Desktop demonstrations of encryption workflows
  • Backend/API demos with deployable crypto endpoints
  • Portfolio projects showing full-stack delivery (local app + cloud API)

Roadmap

  • Add file encryption/decryption support
  • Add key export/import options
  • Add persistence for recent operations
  • Expand automated test coverage
  • Package native installers for macOS/Windows/Linux

See open issues for a full list of proposed features (and known issues).

Contributing

Contributions are welcome! Feel free to submit issues or pull requests with bug fixes, improvements, or new features.

  • Fork the Project
  • Create your Feature Branch (git checkout -b feature/AmazingFeature)
  • Commit your Changes (git commit -m 'Add some AmazingFeature')
  • Push to the Branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

Contributors

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Spencer Jones πŸ“§ jonesspencer99@icloud.com
πŸ”— GitHub Profile
πŸ”— Project Repository

About

Java project with a modern Swing desktop app and a deploy-ready web API for encryption/decryption with multiple algorithms.

Topics

Resources

License

Stars

Watchers

Forks

Contributors