WAP to Implement One Time Pad Algorithm
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char pt[50],key[50],ct[50];
int i,n;
printf("Enter Plain Text\n");
gets(pt);
printf("Enter Key\n");
gets(key);
if(strlen(pt)==strlen(key))
{
for(i=0;i<strlen(pt);i++)
{
pt[i]=pt[i]-96;
key[i]=key[i]-96;
ct[i]=pt[i]+key[i];
while(ct[i] > 25)
{
ct[i]=ct[i]-26;
}
}
for(i=0;i<strlen(pt);i++)
{
ct[i]+=96;
printf("%c",ct[i]);
}
}
else
{
printf("\nPlain Text and Key Have No Same Length");
}
getch();
return 0;
}