A comprehensive Java implementation of classic cryptography algorithms, encoding/decoding schemes, and hashing mechanisms built from scratch using core Java logic without relying on external security libraries.
- Overview
- Project Architecture & Directory Structure
- Supported Algorithms & Implementation Details
- Prerequisites
- Compilation & Execution Guide
- Detailed Walkthrough of Modules
- License
This repository contains clean, core Java programs designed to demonstrate fundamental cryptographic operations and data representation transformations. Each module is self-contained with standard interactive console inputs (java.util.Scanner), making it ideal for educational purposes, security foundational studies, and algorithm analysis.
Encryption-Decryption-Encoding-Decoding/
├── Encryption/ # Symmetric and substitution cipher algorithms
│ ├── Ceaser_Cipher.java # Caesar Cipher encryption
│ ├── ROT13.java # ROT13 substitution encryption
│ ├── Vigenere_cipher.java # Vigenère polyalphabetic cipher encryption
│ └── XOR.java # Bitwise XOR cipher encryption
├── Decryption/ # Reverse operations for cryptographic algorithms
│ ├── Ceaser_cipher.java # Caesar Cipher decryption
│ ├── ROT13.java # ROT13 decryption
│ ├── Vigenere_cipher.java # Vigenère cipher decryption
│ └── XOR.java # Bitwise XOR cipher decryption
├── Encode/ # Binary and text encoding schemes
│ ├── Base_64.java # Custom 6-bit chunking Base64 encoder
│ ├── binary.java # ASCII character to 8-bit binary string encoder
│ ├── MorseCode.java # Alphanumeric text to Morse Code (. / -) encoder
│ ├── Unix_to_Unix.java # UUEncoding (Unix-to-Unix binary-to-text) encoder
│ └── URL.java # Percent-encoding for special URL characters
├── Decode/ # Reverse transformations for encoding schemes
│ ├── Base64.java # Base64 decoder back to plain text
│ ├── Binary.java # 8-bit binary string to plain ASCII decoder
│ ├── MorseCode.java # Morse Code (. / -) to ASCII text decoder
│ ├── Unix-to-Unix.java # UUDecoding back to ASCII text
│ └── URL.java # URL percent-decoding back to plain text
├── Hashing/ # One-way cryptographic hash functions
│ └── SHA_256.java # Custom SHA-256 block infrastructure & 512-bit message padding
├── LICENSE # MIT License
└── README.md # Detailed documentation
-
Caesar Cipher (
Ceaser_Cipher.java/Ceaser_cipher.java)- Mechanism: Shifts alphabetic characters by a user-defined integer key modulo 26 (
(c - 'a' + key) % 26). - Preservation: Preserves case (uppercase and lowercase letters are handled separately); non-alphabetic characters remain unchanged.
- Mechanism: Shifts alphabetic characters by a user-defined integer key modulo 26 (
-
ROT13 (
ROT13.java)- Mechanism: A fixed special case of the Caesar cipher using a fixed key shift of 13 positions (
(c - 'a' + 13) % 26). - Symmetric nature: Shifting twice by 13 results in the original text (26-letter alphabet).
- Mechanism: A fixed special case of the Caesar cipher using a fixed key shift of 13 positions (
-
Vigenère Cipher (
Vigenere_cipher.java)- Mechanism: Polyalphabetic substitution cipher using a repeated keyword.
- Key Expansion: Automatically extends/repeats the key string to match the length of the plaintext string before applying modular shifts.
-
XOR Cipher (
XOR.java)- Mechanism: Bitwise XOR (
^) operation between character ASCII binary representations and key binary representations expanded across 8-bit byte frames.
- Mechanism: Bitwise XOR (
-
Base64 (
Base_64.java/Base64.java)-
Mechanism: Converts text into 8-bit binary chunks, concatenates them into a unified bit stream, groups them into 6-bit blocks, and maps each 6-bit index to the Base64 index table (
A-Z,a-z,0-9,+,/). Appends0padding bits where required.
-
Mechanism: Converts text into 8-bit binary chunks, concatenates them into a unified bit stream, groups them into 6-bit blocks, and maps each 6-bit index to the Base64 index table (
-
Binary Encoding (
binary.java/Binary.java)-
Mechanism: Converts each ASCII character of the input string into a padded 8-bit binary representation (e.g.,
'A'$\rightarrow$ 01000001).
-
Mechanism: Converts each ASCII character of the input string into a padded 8-bit binary representation (e.g.,
-
Morse Code (
MorseCode.java)-
Mechanism: Maps letters (A–Z), numbers (0–9), and special punctuation (
.,,,?,!,/, etc.) to standard International Morse Code signals composed of dots (.) and dashes (-).
-
Mechanism: Maps letters (A–Z), numbers (0–9), and special punctuation (
-
UUEncoding (
Unix_to_Unix.java/Unix-to-Unix.java)-
Mechanism: Historical Unix-to-Unix encoding scheme that converts binary/text streams into 6-bit printable ASCII characters (offset by ASCII code 32), adding length byte headers and grave accent (
`) padding.
-
Mechanism: Historical Unix-to-Unix encoding scheme that converts binary/text streams into 6-bit printable ASCII characters (offset by ASCII code 32), adding length byte headers and grave accent (
-
URL Percent Encoding (
URL.java)-
Mechanism: Replaces reserved or non-alphanumeric characters (such as space
,!,#,$,&,=) with their corresponding%HEXASCII representations (e.g., space becomes%20).
-
Mechanism: Replaces reserved or non-alphanumeric characters (such as space
-
SHA-256 (
SHA_256.java)-
Mechanism: Custom low-level implementation of SHA-256 block creation and message preprocessing:
- Converts UTF-8 input string to binary bits.
- Applies 512-bit block calculation.
- Performs primary padding (
1bit appended as0s), intermediate zero-padding, and 64-bit Big-Endian length attachment. - Constructs block infrastructure (
blockInfraStructure) mapping 32-bit unsigned words ($W_0 \dots W_{15}$ ).
-
Mechanism: Custom low-level implementation of SHA-256 block creation and message preprocessing:
- Java Development Kit (JDK): JDK 8 or higher (JDK 11 / JDK 17 / JDK 21 recommended).
- Terminal / Command Prompt / Shell access.
Verify your local Java installation:
java -version
javac -versionNavigate to the project root directory before executing compilation commands:
cd /Users/pasu/Desktop/Encryption# Compile
javac Encryption/Ceaser_Cipher.java
# Run Encryption
java -cp Encryption Ceaser_cipherSample Prompt:
Plaintext: Hello World
Key: 3
Plaintext: Hello World
Ciphertext: Khoor Zruog
--------------------------
javac Encryption/ROT13.java
java -cp Encryption ROT13javac Encryption/Vigenere_cipher.java
java -cp Encryption Vigenere_cipherjavac Decryption/Ceaser_cipher.java
java -cp Decryption Ceaser_cipherSample Prompt:
ciphertext: Khoor Zruog
Key: 3
Ciphertext: Khoor Zruog
Plaintext: Hello World
--------------------------
javac Decryption/Vigenere_cipher.java
java -cp Decryption Vigenere_cipherjavac Encode/Base_64.java
java -cp Encode base64_encodejavac Encode/binary.java
java -cp Encode binaryjavac Encode/MorseCode.java
java -cp Encode MorseCode_encodejavac Decode/Base64.java
java -cp Decode base64_decodejavac Decode/Binary.java
java -cp Decode Binary_decodejavac Decode/MorseCode.java
java -cp Decode MorseCode_Decodejavac Hashing/SHA_256.java
java -cp Hashing SHA_HashSample Output:
Input: Hello World
Combined Length of Total Blocks: 512
Total blocks used: 1
| Category | File | Main Class | Core Technique |
|---|---|---|---|
| Encryption | Ceaser_Cipher.java |
Ceaser_cipher |
Alphabet Modular Shift |
| Encryption | ROT13.java |
ROT13 |
13-Position Shift |
| Encryption | Vigenere_cipher.java |
Vigenere_cipher |
Keyword Polyalphabetic Shift |
| Encryption | XOR.java |
XOR |
Bitwise XOR (^) on 8-bit ASCII |
| Decryption | Ceaser_cipher.java |
Ceaser_cipher |
Reverse Modular Shift |
| Decryption | ROT13.java |
ROT13 |
13-Position Reverse Shift |
| Decryption | Vigenere_cipher.java |
Vigenere_cipher |
Key-based Reverse Substitution |
| Decryption | XOR.java |
XOR |
Symmetric Bitwise XOR |
| Encode | Base_64.java |
base64_encode |
8-bit to 6-bit Base64 Table Mapping |
| Encode | binary.java |
binary |
ASCII Byte to 8-bit Binary String |
| Encode | MorseCode.java |
MorseCode_encode |
Lookup Map to Dots and Dashes |
| Encode | Unix_to_Unix.java |
UUEncoding |
Unix Binary-to-ASCII Encoding |
| Encode | URL.java |
URL_encoding |
Reserved Char to Percent-Encoding |
| Decode | Base64.java |
base64_decode |
Base64 Index to 8-bit Byte Reconstruction |
| Decode | Binary.java |
Binary_decode |
8-bit Binary Chunk to ASCII Char |
| Decode | MorseCode.java |
MorseCode_Decode |
Dot/Dash Tokens to ASCII |
| Decode | Unix-to-Unix.java |
UUDecoding |
Unix UUDecode Stream to ASCII |
| Decode | URL.java |
URL_decoding |
Percent-Hex Tokens to ASCII |
| Hashing | SHA_256.java |
SHA_Hash |
SHA-256 Preprocessing, Padding & Block Split |
This repository is licensed under the MIT License. Feel free to use, modify, and distribute for learning and development.