Monday, October 22, 2018

Rail fence cipher using C programming language


This is a code for Rail fence cipher using C programming language.



Rail fence cipher:-
Source code:-

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{ int i,j,k,l;
char a[20],c[20],d[20];
//clrscr();
printf("\n**********RailFence**********");
printf("\nEnter the input string: ");
gets(a);
l=strlen(a);
for(i=0,j=0;i<l;i++)
{ if(i%2==0)
c[j++]=a[i];
}
for(i=0;i<l;i++)
{ if(i%2==1)
c[j++]=a[i];
}
c[j]='\0';
printf("\nCipher text after applying rail fence: ");
printf("\n%s",c);
if(l%2==0)
k=l/2;
else
k=(l/2)+l;
for(i=0,j=0;i<k;i++)
{ d[j]=c[i];
j=j+2;
}
for(i=k,j=1;i<l;i++)
{ d[j]=c[i];
j=j+2;
}

getch();
}

Output:-


Diffie–Hellman key exchange using C programming language

This is a code for  Diffie–Hellman key exchange  using C programming language. Diffie–Hellman key exchange :- Source code:- #in...