## DEV Community

Karan-Munjani

Posted on • Updated on

# Playfair Cipher Encryption Program 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 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.

# Programming Playfair Cipher:

## 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!