-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prac2.c
38 lines (38 loc) · 797 Bytes
/
Prac2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char p[100], k[30], q[30], c[100], d[100];
int i, j;
printf("Enter plain text: ");
gets(p);
for (i = 0; i < 26; i++)
{
q[i] = i + 97;
printf("\t %c", q[i]);
// k[i]=getche();
k[i] = getch();
printf("%c", k[i]);
}
for (i = 0; p[i] != NULL; i++)
{
int index = p[i] - 97;
c[i] = k[index];
}
printf("\nCipher text is: ");
puts(c);
for (i = 0; c[i] != NULL; i++)
{
for (j = 0; k[j] != NULL; j++)
{
if (c[i] == k[j])
{
d[i] = q[j];
}
}
}
printf("Decripted text is: ");
puts(d);
getch();
}