-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecrypt.c
More file actions
121 lines (108 loc) · 2.23 KB
/
Copy pathdecrypt.c
File metadata and controls
121 lines (108 loc) · 2.23 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include<stdio.h>
#include<ctype.h>
void caesar(char text[100],int s)
{
int i;
char result[100];
for (i=0;text[i]!='\0';i++)
{
result[i] = (char)((text[i]+s-65)%26 + 65);
}
result[i]='\0';
printf("Encoded: %s\n",result);
}
char * mstr(char x) {
switch (x) {
case 'A':
return ".- ";
case 'B':
return "-... ";
case 'C':
return "-.-. ";
case 'D':
return "-.. ";
case 'E':
return ". ";
case 'F':
return "..-. ";
case 'G':
return "--. ";
case 'H':
return ".... ";
case 'I':
return ".. ";
case 'J':
return ".--- ";
case 'K':
return "-.- ";
case 'L':
return ".-.. ";
case 'M':
return "-- ";
case 'N':
return "-. ";
case 'O':
return "--- ";
case 'P':
return ".--. ";
case 'Q':
return "--.- ";
case 'R':
return ".-. ";
case 'S':
return "... ";
case 'T':
return "- ";
case 'U':
return "..- ";
case 'V':
return "...- ";
case 'W':
return ".-- ";
case 'X':
return "-..- ";
case 'Y':
return "-.-- ";
case 'Z':
return "--.. ";
default:
return "/";
}
}
void morse(char s[100]) {
for (int i = 0; s[i] != '\0'; i++)
printf("%s ",mstr(s[i]));
}
int main()
{
short int a,s;
char msg[100];
printf("Input message in uppercase.\n");
gets(msg);
printf("\nSelect the encryption method from the following: \n\n");
printf("1. Morse\n2. Caesar Cipher\n3. Vignerre Cipher\n");
//label:
scanf("%d",&a);
switch (a)
{
case 1:
printf("Encoded: ");
morse(msg);
break;
case 2:
{printf("\nCaesar Cipher\nEnter the shift : ");
scanf("%d", &s);
caesar(msg, s);
break; }
case 3:
printf("Vn\n");
//vignerre(msg);
break;
default:
{
printf("\nInput valid integer.\n");
//goto label;
}
}
scanf("%d",&a);
}