Skip to content

Heperowt/One_Time_Pad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

One-Time Pad (OTP) Encryption - Jupyter Notebook

This repository contains a step-by-step Jupyter Notebook demonstrating the One-Time Pad (OTP) encryption algorithm. OTP is a classical cryptography technique that, when implemented correctly, provides perfect secrecy (information-theoretic security) and cannot be cracked, even with infinite computing power.

This notebook is structured for educational purposes, breaking down the encryption process into easily digestible chunks.

🚀 Overview

The notebook covers two main approaches to OTP encryption:

  1. Custom Byte-wise Implementation: Demonstrates the core mathematics of OTP using the bitwise XOR (^) operation and cryptographically secure random keys generated via os.urandom().
  2. Using External Libraries: Shows a quick, practical implementation using the onetimepad Python library for rapid prototyping.

💻 Installation & Usage

To run this notebook, you will need Jupyter installed on your system.

  1. Clone the repository:

  2. Install the required external library for the second section of the notebook:

    pip install onetimepad

  3. Launch Jupyter Notebook:

    jupyter notebook

Open the .ipynb file and run the cells sequentially.

🧠 How It Works

The core of OTP relies on the XOR operation:

C = P ⊕ K

Where C is the Ciphertext, P is the Plaintext, and K is the Key.

For the encryption to be truly unbreakable, the key must follow three absolute rules:

  1. It must be truly random (or generated by a Cryptographically Secure Pseudo-Random Number Generator like os.urandom()).
  2. It must be at least as long as the plaintext.
  3. It must never be reused in whole or in part.

Releases

No releases published

Packages

 
 
 

Contributors