Cyber Security
End-To-End Encrypted Communication using Python
By Fernet Encryption Algorithm
--
Have you ever wondered how WhatsApp maintains your chats secure to prevent the ‘Man in the Middle’ from viewing them? That’s called ‘End-to-End Encryption’, which encrypts the message before sending using a key, and decrypts the message after the receiver receives it.
Here’s the mini-version of it. I created it for my University project.
Platforms I used:
- Python
- Thingspeak (Ignore if you don’t know. It’s ok.)
(ThingSpeak is an open-source IoT cloud to log data from programs and IoT devices and perform Data Analytics.)
Python Packages to be downloaded:
- urllib
- cryptography
To download these, first install Python. Go to ‘Command Prompt’. Type
pip install <package name
and press Enter.
For example:
pip install urllib
Now, here’s the code that sends the message:
Run it:
Now, type some message and give your own key. The message gets encrypted based on the key, and is sent to the ThingSpeak channel of the access key mentioned in the code.
Observe line 25. When you attach some number or string at the end of the URL, and open it, the data is sent to the cloud.
Encrypted text is shown for your reference.
Important Note: To access ThingSpeak, you need to have a MathWorks account. But in this code, I’m giving my access code. So, you can use it like you don’t need ThingSpeak at all!