This Python project automatically encrypts messages for you, using the key of your choice.
⚠️ Note:
This is not safe encryption for sensitive data, nor secure encryption by modern standards.
It exists for educational purposes only.
- Open the file
mensagem.txt
and write the message you want to encrypt or decrypt (in uppercase or lowercase). - Run the program:
python Encrypto.py
3.Choose the encryption method (Caesar or Monoalphabetic). 4.Follow the instructions shown in the terminal. 5.The result of your encrypted message (or decrypted) will be available in the note block "mensagem_resultado"
Before applying encryption, the program replaces accented characters and special letters (e.g., Ç, É, Ã) with their normalized ASCII equivalents to ensure compatibility with the cipher:
Dictionary of normalization acentuados = { 'Ç': 'C', 'À': 'A', 'Â': 'A', 'Ä': 'A', 'Ã': 'A', 'Å': 'A', 'Æ': 'AE', 'É': 'E', 'È': 'E', 'Ê': 'E', 'Ë': 'E', 'Í': 'I', 'Ì': 'I', 'Î': 'I', 'Ï': 'I', 'Ñ': 'N', 'Ó': 'O', 'Ò': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': 'O', 'Ø': 'O', 'Ú': 'U', 'Ù': 'U', 'Û': 'U', 'Ü': 'U', 'Ý': 'Y', 'À': 'A', 'Á': 'A', 'Ã': 'A', 'Â': 'A', 'Ä': 'A', 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Í': 'I', 'Ï': 'I', 'Ì': 'I', 'Î': 'I', 'Ó': 'O', 'Ò': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': 'O', 'Ú': 'U', 'Ù': 'U', 'Û': 'U', 'Ü': 'U', 'Ÿ': 'Y', 'Œ': 'OE', 'Æ': 'AE' }
This mapping ensures all input is safely processed without Unicode issues.
- Encrypting with the Caesar Cipher Imagine you have the text "HELLO" and want to encrypt it with a shift of 3. This means each letter in the word (HELLO) will be replaced by the letter that is 3 positions ahead of it in the alphabet:
H → K (H + 3 positions)
E → H (E + 3 positions)
L → O (L + 3 positions)
L → O (L + 3 positions)
O → R (O + 3 positions)
Thus, the word "HELLO" becomes "KHOOR" after being encrypted with a shift of 3.
- Decrypting with the Caesar Cipher To decrypt the message, the process is reversed. That is, for each encrypted letter, you must shift it in the opposite direction. So, for the word "KHOOR" with a shift of 3:
K → H (K - 3 positions)
H → E (H - 3 positions)
O → L (O - 3 positions)
O → L (O - 3 positions)
R → O (R - 3 positions)
The word "KHOOR" becomes "HELLO" again.
The Caesar Cipher is very simple and easy to break, which makes it insecure for real use. Its main weakness is the fact that it has only 25 possible shift values (in an alphabet with 26 letters). That means an attacker would only need to try 25 different shifts, which can be done very quickly.
Furthermore, Caesar Cipher does not consider the frequency of letters in a language. For example, in a language like Portuguese, the letter "A" is much more common than the letter "X". This means that an attacker could easily analyze the encrypted text and deduce which letter corresponds to which, using techniques such as frequency analysis.
In modern cryptographic terms, the Caesar Cipher is not secure. Although it was useful in ancient times, its simplicity makes it easily breakable using computational tools.
- What Is It? The Monoalphabetic Cipher is a substitution cipher in which each letter in the plaintext is replaced by another unique letter from the alphabet. Unlike the Caesar Cipher, which shifts letters by a fixed amount, the Monoalphabetic Cipher uses a custom substitution alphabet, which can be:
-Manually defined by the user (e.g., A → Q, B → R, C → T, etc.)
-Randomly generated by the system, as long as:
-
No letter maps to itself
-
No duplicates exist in the new alphabet
For example, if the standard alphabet is:
Original: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
And the new alphabet is
Substit.: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M
Then the message "HELLO" would be encrypted as follows:
H → I
E → T
L → S
L → S
O → G
Encrypted result: "ITSSG"
- Decrypting with the Monoalphabetic Cipher To decrypt a message, you need the exact substitution alphabet that was used for encryption. The process is simply reversed: you look up each encrypted letter in the new alphabet and map it back to the corresponding original letter.
Using the same substitution alphabet as above, the encrypted message "ITSSG" would be decrypted like this:
I → H
T → E
S → L
S → L
G → O
Decrypted result: "HELLO"
It is vulnerable to frequency analysis. Letters in any language tend to appear with predictable frequencies (e.g., E is common in English, A in Portuguese). An attacker can analyze the frequency of characters in the ciphertext and compare it to known letter frequency patterns to break the encryption.
If the substitution alphabet is guessed or leaked, the entire message becomes readable instantly.
Therefore, although it's historically significant and fun to experiment with, the Monoalphabetic Cipher is not suitable for protecting real-world data.
João Vitor de Oliveira Lima
🔗 LinkedIn --> www.linkedin.com/in/joãovitordeoliveira-lima
- Clone the repository:
git clone https://github.com/JOHNcoding9/Encrypto.git
cd Encrypto