Learn to Code via Tutorials on Repl.it!

← Back to all posts
Simple Message Encrypter and Decrypter In Python 3
PythinPython (8)

Simple Message Encrypter and Decrypter In Python 3

Hi, in this tutorial I will be sharing a simple program that scrambles sentences so it is difficult to decipher them (it's not very secure though).

Imports and Variables

We will be using three imports in this program.

The time and replit imports are used to make the program more pleasant to use and the random import will make the message randomly scrambled.
We will also be using three variables.

The alphabet list gives the program characters it can use to scramble the message. The key will later be used to store the information to unscramble the message. And the path will ask the user for what they want to do.

The Program

First we need to ask the user for what they want to do. Let's start with the encryption part.

Next we need to make a loop that replaces characters in the message with randomly picked characters from our alphabet but won't mix anything up.

We also need to generate a key the program can later use. We do this by comparing the old message with the new one.

Now we have the part of the program that unscrambles the message. This part of the program does that by taking the odd number characters from the key and replacing them in the scrambled message with the even characters.

I hope you liked this tutorial. Here is the full code.


Have you made a decrypter aswell? @PythinPython

PythinPython (8)

@MATTHEWBECHTEL Yes, it's the second part of the code above.


Great, I think a encrypted and decrypter would be a better title.
Upvote my comment if it is helpful.

PythinPython (8)

@MATTHEWBECHTEL Sure, I'll change the title. Did you like the program though?


Don’t have time to run to right now, I have time in an hour and a half from now though. @PythinPython
Don’t forget to Upvote my comments.