-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonoalpha.c
62 lines (52 loc) · 844 Bytes
/
monoalpha.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<conio.h>
void main()
{
char key[26], msg[50], enc[50];
char comp[26];
int i, j, choice;
char x;
for (i = 0; i < 26; i++)
{
comp[i] = 97 + i;
}
printf("\t1. Sender\n\t2. Receiver\n");
scanf("%d", &choice);
if (choice == 1)
{
printf("enter plain text : ");
scanf("%s", msg);
printf("enter the key :");
scanf("%s", key);
for (i = 0; msg[i] != NULL; i++)
{
j = 0;
while (msg[i] != comp[j])
{
j++;
}
enc[i] = key[j];
printf("%c", enc[i]);
}
}
else
{
printf("enter encrypted text:");
scanf("%s", enc);
printf("enter the key:");
scanf("%s", key);
for (i = 0; enc[i] != NULL; i++)
{
j = 0;
while (enc[i] != key[j])
{
j++;
}
msg[i] = comp[j];
printf("%c", msg[i]);
}
}
getchar();
getchar();
}