# One Time Pad Calculator

Please don't use this for any actually sensitive application. This is purely for demonstration purposes.

## Cleartext

Base64 encoded

## Random pad

Key length to generate:

## Cyphertext

Base64 encoded

## What is this?

The one-time pad is a cryptographic algorithm that boasts "perfect secrecy." This cypher involves combining the cleartext with a random key of equal length in such a way that two successive applications of the cypher will return the original cleartext. Here I'm using the XOR operation but in the past modular arithmetic is a way to calculate the cypher by hand.

The key to its unbreakable nature lies in the fact that, given a ciphertext, any cleartext is just as likely as any other cleartext. This property gives us "perfect secrecy."

However, there is a significant assumption underlying this concept: that the key used is a truly random number, devoid of any biases an attacker might predict or exploit. Achieving this randomness is a challenge in itself. Additionally, the randomly generated key must be kept secret and transmitted to the recipient of the ciphertext. Furthermore, a new key must be supplied to each party every single time.

In practice, the one-time pad is infrequently used because if we possessed a means of transmitting a key that is at least as long as our cleartext, we would already have a secure communication channel. However, the one-time pad may prove useful if both parties anticipate communicating over an untrusted medium in the future and can pre-exchange one-time pads for later use.