Posts

Showing posts with the label Playfair Cipher

Playfair Cipher C++ Program - The Coding Shala

Home >> Computer Network >> Playfair Cipher Playfair Cipher C++ Program Here is the C++ program to implement the Playfair Cipher. C++ Code:  #include<bits/stdc++.h> using namespace std; void encrypt (string key){ pair < char ,pair < int , int > > pa[ 25 ]; //store i j value of char int visited[ 26 ] = { 0 }; char a[ 5 ][ 5 ]; char b[ 5 ][ 5 ]; char ch1,ch2,c1,c2; int i,j,i1,j1,i2,j2; int count = 0 ; for (i = 0 ; i < 5 ; i ++ ){ if (count == key.size()){ break ; } for (j = 0 ; j < 5 ; j ++ ){ if (count == key.size()){ break ; } else if (key[count] != 'j' ){ //skip j //cout << key[count] << endl; while (visited[key[count] - 'a' ] == 1 ){ //skip same char count ++ ; } if (visited[key[count] - 'a' ] == 0 ){ //first time store it a[i][j] = key[count]; visited[key[count] - 'a' ] = 1 ; } } count ++ ; } }...