-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprob19.c
More file actions
45 lines (37 loc) · 1.76 KB
/
prob19.c
File metadata and controls
45 lines (37 loc) · 1.76 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
//encryption and decreption function code and there uses
#include <stdio.h>
#include <string.h>
void encrypt(char str[]) {
for (int i = 0; i < strlen(str); i++) {
str[i] = str[i] + 1;
}
}
void decrypt(char str[]) {
for (int i = 0; i < strlen(str); i++) {
str[i] = str[i] - 1;
}
}
int main() {
char str[100], choice[10];
printf("Enter text: ");
scanf("%s", str);
printf("Do you want to encrypt the text? (yes/no): ");
scanf("%s", choice);
if (strcmp(choice, "yes") == 0) {
encrypt(str);
} else {
printf("Your text is open source.\n");
}
printf("Do you want to read the text? (yes/no): ");
scanf("%s", choice);
if (strcmp(choice, "yes") == 0) {
printf("Text: %s\n", str);
}
printf("Do you want to decrypt the text? (yes/no): ");
scanf("%s", choice);
if (strcmp(choice, "yes") == 0) {
decrypt(str);
printf("Decrypted Text: %s\n", str);
}
return 0;
}