Encryption Using Playfair Cipher In Python

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 …


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:

  1. Convert plaintext into digraphs (i.e., into pair of two letters)
  2. Generate a Cipher Key Matrix
  3. 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Encryption Using Playfair Cipher In Python." Karan-Munjani | Sciencx - Friday October 1, 2021, https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/
HARVARD
Karan-Munjani | Sciencx Friday October 1, 2021 » Encryption Using Playfair Cipher In Python., viewed ,<https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/>
VANCOUVER
Karan-Munjani | Sciencx - » Encryption Using Playfair Cipher In Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/
CHICAGO
" » Encryption Using Playfair Cipher In Python." Karan-Munjani | Sciencx - Accessed . https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/
IEEE
" » Encryption Using Playfair Cipher In Python." Karan-Munjani | Sciencx [Online]. Available: https://www.scien.cx/2021/10/01/encryption-using-playfair-cipher-in-python/. [Accessed: ]
rf:citation
» Encryption Using Playfair Cipher In Python | Karan-Munjani | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.