A small desktop app built with Tkinter that encodes and decodes text messages using a shared key. Type a message, a key and a mode, and press RESULT. The same key must be used to decode a message that was encoded.
The goal of the project is to encode and decode messages using a common key, using the Tkinter and base64 modules from the Python standard library.
Note: this is a simple key-based obfuscation technique for learning purposes. It is not strong encryption and should not be used to protect sensitive information.
- Encode a message with a key and get a URL-safe Base64 string
- Decode that string back to the original message with the same key
- Simple Tkinter window with MESSAGE, KEY and MODE fields, and RESULT, RESET and EXIT buttons
- Friendly messages for an invalid mode, a missing key, or text that cannot be decoded
- No third-party dependencies
- Encode: each character of the message is shifted by the matching character of the key (the key repeats as needed):
(ord(message_char) + ord(key_char)) % 256. The resulting text is encoded as URL-safe Base64. - Decode: the Base64 text is decoded and the shift is reversed with the same key.
Because the shift is taken modulo 256, characters outside the Latin-1 range (code points above 255) will not survive an encode/decode round trip.
- Python 3
- Tkinter (GUI) and
base64(both in the standard library)
git clone https://github.com/digantadatta/Python-Message-Encoder-Decorder.git
cd Python-Message-Encoder-DecorderNo packages need to be installed (see requirements.txt). Tkinter is bundled with the official Python installers for Windows and macOS; on Debian/Ubuntu install it with sudo apt install python3-tk.
python MessageEncodeDecode.py- Enter
Hello Worldin MESSAGE,mykeyin KEY, andein MODE, then press RESULT. The result field showswrXDnsOXw5HDqMKNw5DDmsOXw6XDkQ==. - To decode, paste that result into MESSAGE, keep the key
mykey, set MODE tod, and press RESULT. The result field showsHello World. - RESET clears all fields; EXIT closes the window.
You can also use the functions from Python:
from MessageEncodeDecode import Encode, Decode
token = Encode("mykey", "Hello World")
print(Decode("mykey", token)) # Hello World.
├── MessageEncodeDecode.py # Encode/Decode functions and the Tkinter UI
├── requirements.txt # No third-party dependencies
├── LICENSE
└── .github/workflows/ci.yml # CI: compile and flake8
Released under the MIT License.