Cryptography 1
This repository contains JavaScript implementations of two fundamental cryptographic algorithms:
Caesar Cipher (Encryption and Decryption)
Euclidean Algorithm (Greatest Common Divisor – GCD)
Both algorithms are implemented in a single file (index.js) using hardcoded input values to clearly demonstrate their functionality.
📚 Overview
Cryptography relies heavily on mathematical concepts and algorithmic transformations. This project introduces:
Basic encryption and decryption using substitution ciphers
Number theory fundamentals used in modern cryptographic systems
🛠️ Technologies Used
JavaScript
Node.js
📂 Project Structure Cryptography-1/ ├── index.js └── README.md
🔐 Caesar Cipher Description
The Caesar Cipher is a classical substitution cipher where each alphabetic character in a message is shifted forward by a fixed number of positions (the key).
Uppercase and lowercase letters are preserved
Non-alphabetic characters remain unchanged
Modular arithmetic is used to handle wrap-around at the end of the alphabet
Hardcoded Input Message: "Hello World" Key: 3
Output Original Message: Hello World Encrypted Message: Khoor Zruog Decrypted Message: Hello World
Explanation
Each character is converted to its ASCII value, shifted using modulo 26, and then converted back to a character. Decryption reverses the shift using the same key.
🔢 Euclidean Algorithm (GCD) Description
The Euclidean Algorithm is an efficient method for computing the Greatest Common Divisor (GCD) of two integers.
It repeatedly replaces the larger number with the remainder obtained from dividing it by the smaller number until the remainder becomes zero.
Hardcoded Input First Number: 48 Second Number: 18
Output First Number: 48 Second Number: 18 Greatest Common Divisor (GCD): 6
Ensure Node.js is installed on your system, then execute:
node index.js
This command runs both the Caesar Cipher and Euclidean Algorithm using the predefined hardcoded values.
🧠 Cryptographic Significance
Caesar Cipher introduces the concept of symmetric encryption
Euclidean Algorithm is foundational in:
RSA cryptography
Modular inverses
Elliptic Curve Cryptography (ECC)
