Join with us

Playfair Cryptography in C++, C and C#

Hi there, this time I want to share about Playfair Cryptography in my post before this, I inform you another two cryptography technique there are Homofon and  Transposition cryptography.
okay just to the point,

here they are the source:

int main(){
 
    printf("------------------------------\n");
    printf("|||| Created using DevC++ ||||\n");
    printf("||||     Language C++     ||||\n");
    printf("------------------------------\n");
    printf("||||     Wisnu Sadewo     ||||\n");
    printf("------------------------------\n");
    printf("input plainteks: ");
    printf("\n------------------------------\n");
    gets(plainteks);
    pl=strlen(plainteks);
    printf("\n------------------------------\n");
    printf("\ninput key______: ");
    printf("\n------------------------------\n");
    gets(key);
    encryp(plainteks,key);
    printf("\n------------------------------\n");
    printf("\n------------------------------\n");
    printf("|||||_______ E O F _______|||||\n");
    printf("-------------------------------\n");
    printf("|||_THANK'S FOR TAKE A PEEK_|||\n");
    printf("-------------------------------\n");
    getch();
    return 0;
    }
 
void encryp(char teks[],char key[])
     {
     int inb[50];
     int ubahb;
     int c;
   
     // ubah b dengan a
     ubahb=0;
     for(a=0;a       {
          if (teks[a] == 'b')
          {
             teks[a] == 'a';
             inb[ubahb] == a;
             ubahb=ubahb+1;
          }
       }
   
      //plus huruf 'z' pada pasangan huruf yang sama
     for(a=0;a     {
          if (teks[a] == teks[a+1])
          {
               for(b=strlen(teks);b>a+1;b--)
               {
                     teks[b]= teks[b-1];                              
               }
               teks[a+1]='z';
               a=a+1;        
          }
     }                          
                               
      //plus huruf 'z' bila jumlah kata ganjil
     if (strlen(teks)%2==1)
     {
          teks[strlen(teks)]='z';                      
     }
     printf("\n----------------------------\n");
     printf("\nbentuk bigram plainteks : ");
     for(a=0;a     {
          if(a%2==1)
          {
               printf("%c ",teks[a]);        
          }
          else
          {
               printf("%c",teks[a]);
          }
     }                                
   
     //Proses menampilkan matriks
     printf("\n------------------------------\n");
     printf("\n\nMatriks : \n\n");
     for(a=0;a {
flag=1;
for(b=0;b        {
      if(key[a] == key[b])
               {
                  flag=0;
               }
        }

if(flag==1)  
        {
               matriks[row][col]=key[a];
               printf(" %c",matriks[row][col]);
               col++;
  if(col==5)
               {
                  printf("\n");
 col=0;
 row=row+1;
               }
         }
 }

 for(a=0;a<26 a="" p="">      {
          flag=1;
          for(b=0;b          {
              if(key[b]==a+97)
              {
                  flag=0;
              }
          }
          if(flag==1 && a!=9)
          {
              matriks[row][col]=a+97;
 printf(" %c",matriks[row][col]);
 col++;
              if(col==5)
              {
       row=row+1;
       col=0;
       printf("\n");
              }
          }
       }
       printf("\n------------------------------\n");


and you can find the full source via this link, which I shrieked using this ==>> here the source or here
Playfair Cryptography in C++, C and C# Playfair Cryptography in C++, C and C# Reviewed by Izuka on Sunday, October 06, 2013 Rating: 5

No comments:

Powered by Blogger.