Sunday, February 5, 2017

Simple Railfense - Encryption


//Simple Railfense Technique - Sender side encryption logic.
#include<stdio.h>
int main()
{
  char str[20], str1[10]="", str2[10]="";
  int i, cnt1=0, cnt2=0;

  printf("Enter your plain text:");
  gets(str);

  for(i=0; i<strlen(str); i++)
  {
  if( i%2 == 0)
  {
str1[cnt1++]=str[i];
  }
  else
str2[cnt2++]=str[i];
  }
  printf("Encrypted Text = %s%s",str1,str2);
  return 0;
}

Output of the program

Enter your plain text:HelloStudent
Encrypted Text = HlotdnelSuet



No comments:

Post a Comment