/*Playfair Key Matrix Generation: Keyword validation according to the specification given in the algorithm.*/
#include<stdio.h>
int main(){
char key[10];
int i,j,flag=0, cnt=0, key_check[26]={};
printf("Enter your keyword:");
scanf("%s",key);
//Logic to count character frequency in MONARCHY
for(i=0; i<strlen(key); i++)
{
key_check[key[i]%65]++;
}
for(i=0; i<26; i++)
{
if(key_check[i] > 1)
flag=1;
//Logic to display frequency
//printf("%c=%d \n",i+65, key_check[i]);
}
if(flag==1)
printf("Keyword %s is not suitable for generating Playfair Key Matrix.", key);
else
printf("Keyword %s is ok for generating Playfair Key Matrix.", key);
return 0;
}
//This program will check only keywords enter in Capital letters.
Output - 1
Enter your keyword:MONARCHY
Keyword MONARCHY is ok for generating Playfair Key Matrix.
Output - 2
Enter your keyword:HELLO
Keyword HELLO is not suitable for generating Playfair Key Matrix.