Simple one-time pad (OTP) encryption

Overview

Introduction

What you will make

In this resource you will learn how to create and use an encryption technique known as the one-time pad. This method of encryption will allow you to send secret messages to your friends and, as long as you’re careful, the messages will be unbreakable.

What you will learn

By writing the secret agent chat program, you will learn:

  • How random numbers can be used to encrypt messages
  • How iteration can be used to encrypt individual characters
  • Why techniques such as the Caesar cipher are insecure
  • Why it’s important to keep your keys a secret

What you will need

  • A computer with Python 3 installed

Secret agent chat

Image of OTP

Cryptography may be a way of disguising the contents of your message, to form it harder for your enemies to read. one amongst the primary sorts of cryptography was utilized by the Roman Emperor general, and is now called the Caesar Cipher.

During World War II the German military thought they'd developed an ideal method of encrypting messages, using something called an Enigma machine.

The German military was wrong though. because of some clever Polish mathematicians and a British mathematician called Alan Turing, the Enigma messages were decrypted, and this helped the Allies win the war.

A one-time pad (OTP) may be a different method of encryption. Imagine Alice wants to send a secret message to Bob, without Eve knowing what the message says. Alice first picks a key, which will be a number such as 3. Alice then tells Bob the key.

When using an OTP, a string of random numbers is generated and shared between Alice and Bob. Each letter of the message is then shifted by the corresponding number within the OTP, so each letter has its own individual key! As long as Eve doesn’t have the OTP, the message is impossible to decrypt.

Note à bien

While a one-time pad offers perfect secrecy, you still have to be careful if you want to remain really secure, and there are some issues with this program.

  • To send encrypted messages to each other, you can use email, SMS or even social media such as Facebook or Twitter. It won’t even matter if your posts are public, as the only person who could decrypt the message is your friend.
  • Once you’ve generated your OTP, such as by generating 100 sheets, you need to transfer them to the person you want to communicate with. You can’t send them electronically, such as by email, as this is insecure.

Probably the most secure method is giving them to your friend on a storage device, such as an SD card or USB flash memory.

  • The OTP method is only secure if you and your friend keep the OTP secure.
  • You and your friend need to be sure which OTP you’re using. The best way of doing this is by starting with otp0.txt and then deleting it when you’ve encrypted or decrypted a message. You can then progress to using otp1.txt.
  • The OTP relies on the randomness of the random number generator. If the generator isn’t truly random, then the OTP could be cracked. Python’s random module is probably not the best way of generating random numbers.
  • Your message can’t be longer than the length of the sheet from the OTP. If you’re not sure how long your messages will be, it’s better to generate large sheets just in case.

What next?

  • Can you alter the program so that capital letters are preserved?
  • Can you alter the program so that punctuation is also encrypted?

Using the Program

The Program is very easy to use; I write the options as a list that you can understand each one of them.

ScreenShoot

The default password = '123456' (You can change it from the source code)

You might also like...
Aza this is a text encryption software

Aza text encryptor General info Aza this is a text encryption software Help command: python aza.py --help Examples python aza.py --text "Sample text h

This is a basic encryption and decryption program made in python.

A basic encryption and decryption program to visualize how the process of protecting data works.

A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

Stenography encryption script
Stenography encryption script

ImageCrypt Project description Installation Usage Project description Project AlexGyver on Python by TheK4n Design by Пашушка Byte packing in decimal

Linear encryption software programmed with python
Linear encryption software programmed with python

Echoder linear encryption software programmed with python How does it work? The text in the text section runs a function with two keys entered keys mu

Message Encrypt and decrypt software // allows you  to encrypt the secrete message and decrypt Another Encryption Message. |
Message Encrypt and decrypt software // allows you to encrypt the secrete message and decrypt Another Encryption Message. |

Message-Encrypy-Decrypt-App Message Encrypt and decrypt software // allows you to encrypt the secrete message and decrypt Another Encryption Message.

An extreme encryption for everyone, encrypt your text before sending to anyone.

An extreme encryption for everyone, encrypt your text before sending to anyone. Alphabets and numbers are going to be encrypted like a hell

gcrypter: an encryption algorithm based on bytes and their correspondent numbers to encode strings
gcrypter: an encryption algorithm based on bytes and their correspondent numbers to encode strings

gcrypter: an encryption algorithm based on bytes and their correspondent numbers to encode strings

Advanced Digital Envelope System Using Cryptography Techniques (Encryption & Decryption)

Advanced-Digital-Envelope-System Advanced Digital Envelope System Using Cryptography Encryption Techniques The digital envelope system is the techniqu

Owner
Rabih ND
<> Learning (& Coding) is my Secondary Oxygen for Staying Alive.
Rabih ND
Simple encryption-at-rest with key rotation support for Python.

keyring Simple encryption-at-rest with key rotation support for Python. N.B.: keyring is not for encrypting passwords--for that, you should use someth

Dann Luciano 1 Dec 23, 2021
Simple python program to encrypt files with AES-256 encryption

simple-enc Simple python program to encrypt files with AES-256 encryption Setup First install "pyAesCrypt" using pip. Thats it! Optionally you can add

Hashm 2 Jan 19, 2022
Simple encryption/decryption utility using Pycryptodome module. Working with AES and RSA algorithms.

EncypherUtil Simple encryption/decryption utility using PyCryptodome module. Working with AES and RSA algorithms. THIS UTILITY IS NOT LICENSED AS CRYP

Egor Yakubovich 0 Jun 14, 2022
C0mptCrypt - An object-oriented, minamalistic, simple encryption library in Python

C0mptCrypt allows you to encrypt strings of text. It can only be decrypted using C0mptCrypt and not by random online tools. You can use this for a variety of things from creating passwords, to encrypting HWIDs.

c0mpt0 4 Aug 22, 2022
A simple and secure password-based encryption & decryption algorithm based on hash functions, implemented solely based on python.

pyhcrypt A simple and secure password-based encryption & decryption algorithm based on hash functions, implemented solely based on python. Usage Pytho

Hongfei Xu 3 Feb 8, 2022
A lightweight encryption library in python.

XCrypt About This was initially a project to prove that I could make a strong encryption but I decided to publish it so that the internet peoples coul

Anonymous 8 Sep 10, 2022
Scrambler - Useful File/Directory Encryption Program

This is a program that is used to scramble/encrypt files on your computer. Do not use this program to do malicious things with. I am not responsible for any damage that you do with this software.

null 0 Oct 1, 2021
Given a string or a text file with plain text , returns his encryption using SHA256 method

Encryption using SHA256 Given a string or a .txt file with plain text. Returns his encryption using SHA256 method Requirements : pip install pyperclip

yuno 3 Jan 24, 2022
Python Encryption Name Game

Python 3.9.7 Encryption Name Game Encrypt a name with numbers using a Caesar cipher! You can choose different numbers to encrypt your name from 1 to o

Armand Brunelle 3 Dec 24, 2021
Python program that handles the creation, encryption and storage of log/journal files. Kinda works like a diary of sorts.

LucaSoft J.O.U.R.N.A.L The J.O.U.R.N.A.L (Just anOther User Redaction & Navigation Assistant by Lucaspec72) is a Python program that handles the creat

Lucaspec72 8 Oct 27, 2021