This content originally appeared on DEV Community and was authored by Karan-Munjani
In this post I'm going to explain you how to code playfair cipher to encrypt plaintext to cipher. So this post is all about encryption program and will soon add decryption program in this series also so stay tuned!
If you don't know how the algorithm works checkout previous post in this series.
So Without further ado, LET'S BEGIN!!👨💻👩💻
Can you recall what were the steps of algorithm?
Yes, You're right!
The Algorithm was consist of three steps:
- Convert plaintext into digraphs (i.e., into pair of two letters)
- Generate a Cipher Key Matrix
- Encrypt plaintext using Cipher Key Matrix and get ciphertext.
Step: 1 Creating function to convert plaintext into digraphs
Step: 2 Function to generate a cipher key matrix
Now we need to locate index of particular character inside cipher key matrix to perform encryption:
Step: 3 Encrypt plaintext using cipher key matrix and get ciphertext
Final Step! Running our code from main method:
Thanks a lot for reading out!
I hope the code with comments was actually sufficient to understand the logic.
Here's the repository link to the whole code file GitHub Repo
But if you still have any doubts feel free to mention below in discussion section, I would love to answer them.
Also drop a heart ❤ if you gained some knowledge!
This content originally appeared on DEV Community and was authored by Karan-Munjani
Karan-Munjani | Sciencx (2021-10-01T05:08:49+00:00) Encryption Using Playfair Cipher In Python. Retrieved from https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.