Monday, 22 April 2013

Polyalphabetic Algorithm in C

This blog is about implementation of Polyalphabetic cipher algorithm in c.

Hope that this will help to understand the concept of Polyalphabetic cipher cipher algorithm.

For any query regarding c/c++ please contact me at khimanichirag@gmail.com


     #include<stdio.h>  
     #include<conio.h>  
     #include<string.h>  
     void main()  
     {  
           char s[30],k[27],c[30];  
           int i,j=0;  
           clrscr();  
           printf("Enter plain text:");  
           gets(s);  
           printf("Enter key value:");  
           gets(k);  
           for(i=0;i<strlen(s);i++)  
           {  
               c[i]=s[i]+(k[j]-97);  
               j++;  
               if(j==strlen(k))  
               {  
                   j=0;  
               }  
           }  
           printf("Your cipher text is: %s",c);  
           getch();  
      }  

No comments:

Post a Comment