Cryptography
1.0
Implementation of Cryptography Algorithms
|
#include <bits/stdc++.h>
Macros | |
#define | ll long long |
#define | pb push_back |
#define | mp make_pair |
Functions | |
string | implmatrix (string s, char mat[][5]) |
int | main () |
#define ll long long |
#define mp make_pair |
#define pb push_back |
string implmatrix | ( | string | s, |
char | mat[][5] | ||
) |
The matrix obtained in the main function is now used here to generate the cipher text. According to playfair algorithm the conditions for swap vary according to the locations of the digrams in the supplied matrix.
< Iteration Variables for the matrix
First case handling
If the the digrams are not located in the same column and same row then we swap the take the digit in the same row but column number of the second member of the diagram and vice versa for the second element of the digram
Second case handling
If the the digrams are located in the same row and different column then we swap the take the digit in the same row but next column number in that row and same is done for the second element of the digram.
Third case handling
If the the digrams are located in the same colum and different row then we swap the take the digit in the same column but next row number in that row and same is done for the second element of the digram.
s | String to be encrypted |
int main | ( | ) |