-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryption
More file actions
30 lines (27 loc) · 810 Bytes
/
Encryption
File metadata and controls
30 lines (27 loc) · 810 Bytes
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
#include <stdio.h>
int main()
{
char text[100];
int key, i;
do
{
printf("\nEnter text to encrypt (or type 'exit' to quit): ");
fgets(text, sizeof(text), stdin);
if (text[0] == 'e' && text[1] == 'x' && text[2] == 'i' && text[3] == 't')
{
printf("\nExiting... 👋\n");
break;
}
printf("Enter key : ");
scanf("%d", &key);
getchar();
for (i = 0; text[i] != '\0'; i++)
{
if ((text[i] >= 'A' && text[i] <= 'Z') || (text[i] >= 'a' && text[i] <= 'z'))
text[i] += key;
}
printf("\n🔒 Encryption complete! Your top-secret message: %s", text);
printf("\nIf this looks like gibberish, je suis désolé 😂\n");
}
while (1);
}