Practical 2
Practical 2
h>
#include <stdlib.h>
#include <string.h>
#define SIZE 30
i = 0;
j = 0;
for (k = 0; k < ks; k++) {
if (dicty[key[k] - 97] == 2) {
dicty[key[k] - 97] -= 1;
keyT[i][j] = key[k];
j++;
if (j == 5) {
i++;
j = 0;
}
}
}
for (k = 0; k < 26; k++) {
if (dicty[k] == 0) {
keyT[i][j] = (char)(k + 97);
j++;
if (j == 5) {
i++;
j = 0;
}
}
}
}
void search(char keyT[5][5], char a, char b, int arr[])
{
int i, j;
if (a == 'j')
a = 'i';
else if (b == 'j')
b = 'i';
int mod5(int a)
{
if (a < 0)
a += 5;
return (a % 5);
}
ks = strlen(key);
ks = removeSpaces(key, ks);
toLowerCase(key, ks);
ps = strlen(str);
toLowerCase(str, ps);
ps = removeSpaces(str, ps);
int main()
{
char str[SIZE], key[SIZE];
strcpy(key, "pearlharbour");
printf("Enter key text: %s\n", key);
strcpy(str, "bwpnrsmualaw");
printf("Enter cipher text: %s\n", str);
decryptByPlayfairCipher(str, key);
return 0;
}