Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Encryption Techniques

A from-scratch Java implementation of classical and modern ciphers, with cryptanalysis routines that recover keys from known plaintext/ciphertext pairs.

Overview

This repository implements a range of encryption algorithms in plain Java, with no cryptography libraries. Each cipher provides encrypt and decrypt, and most classical ciphers also provide an analyse method that performs a known-plaintext attack — given a plaintext and its corresponding ciphertext, it recovers the key. AES-128 and DES are included as full block-cipher implementations operating on hexadecimal input. It started as an information-security course project and is intended for study rather than production use.

Features

  • Ten ciphers implemented by hand (no crypto libraries).
  • Encrypt and decrypt for every cipher.
  • Cryptanalysis (analyse) for the classical ciphers — recovers the key from a known plaintext/ciphertext pair.
  • Frequency-based analysis for the monoalphabetic cipher (analyseUsingCharFrequency).
  • A JUnit 5 test suite (45 tests) covering every cipher.

Ciphers

Cipher Encrypt Decrypt Cryptanalysis
Caesar
Monoalphabetic ✓ (known-plaintext + frequency)
Autokey
Repeating-key (Vigenère)
Playfair
Hill (2×2 & 3×3) ✓ (3×3 key recovery)
Rail fence
Columnar transposition
AES-128
DES

Tech stack

  • Java 17
  • Maven
  • JUnit 5 (Jupiter)

Getting started

Prerequisites

  • JDK 17 or newer
  • Maven

Build and test

git clone https://github.com/Omar-Elhakim/Encryption-Techniques.git
cd Encryption-Techniques
mvn test

The ciphers live in src/main/java/Security/; the JUnit tests in src/test/java/ double as usage examples.

Usage

The ciphers are used as plain Java classes. Example with the Caesar cipher:

import Security.CaeserCipher;

CaeserCipher caesar = new CaeserCipher();

String cipher = caesar.encrypt("meetmeaftertheparty", 3); // "phhwphdiwhuwkhsduwb"
String plain  = caesar.decrypt(cipher, 3);                // "meetmeaftertheparty"

int key = caesar.analyse("meetmeaftertheparty", cipher);  // 3

AES-128 and DES operate on hexadecimal strings:

import Security.AES;

AES aes = new AES();
String cipher = aes.encrypt("0x00112233445566778899aabbccddeeff",
                            "0x000102030405060708090a0b0c0d0e0f");
String plain  = aes.decrypt(cipher,
                            "0x000102030405060708090a0b0c0d0e0f");

Project structure

src/
  main/java/Security/   # cipher implementations
  test/java/            # JUnit tests (also serve as examples)
pom.xml                 # Maven build + JUnit 5 dependency

License

Released under the MIT License.

About

From-scratch Java implementations of classical and modern ciphers (Caesar, Vigenère, Playfair, Hill, rail fence, columnar, AES-128, DES) with known-plaintext cryptanalysis and a JUnit test suite.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages