-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.c
62 lines (52 loc) · 1.4 KB
/
code.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
61
#include <stdio.h>
#include<string.h>
void encrypt(int option,int key)
{
int i, len=0;
char password[200];
printf("\n\t\t\tEnter your password:");
scanf("%s",password);
len = strlen(password);
printf("\n\t\t\tYour encrypted password is: ");
for(i=0; (i<len&& password[i] != '\0'); i++)
printf("%c",password[i]+key);
}
void decrypt(int option,int key)
{
int i, len=0;
char password[200];
printf("\n\t\t\tEnter your encrypted password:");
scanf("%s",password);
len = strlen(password);
printf("\n\t\t\tYour decrypted password is: ");
for(i=0; (i<len && password[i] != '\0'); i++)
printf("%c",password[i]-key);
}
int main()
{
int option;
char ch;
print:
printf("\t\t\tChoose Your Option\n\t\t\t1.ENCRYPTION\n\t\t\t2.DECRYPTION\n\n");
scanf("%d",&option);
if(option==1)
encrypt(option,0XAED);
else if(option==2)
decrypt(option,0XAED);
else
printf("Please Choose Your Option Correctly!");
again:
printf ("\n\t\t\tDo you want to repeat the operation(Y/N): ");
scanf (" %s", &ch);
if(ch == 'y' || ch == 'Y'){
goto print;
}
else if(ch == 'n' || ch == 'N'){
return 0;
}
else{
printf("\n\t\t\tPlease enter Yes or NO.\n");
goto again;
}
return 0;
}