-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvinay.c
More file actions
32 lines (27 loc) · 712 Bytes
/
vinay.c
File metadata and controls
32 lines (27 loc) · 712 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
31
32
#include<stdio.h>
#include<string.h>
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main()
{
char userinput[40];
int key;
printf("enter the message and the key: ");
scanf("%s%d", userinput, &key);
for(int i = 0; i < strlen(userinput); i++) {
userinput[i] = userinput[i] + key;
}
printf("hello owner your current password is %s", userinput);
int userkey;
printf("\nenter the key to decrypt the message: ");
getchar();
scanf("%d", &userkey);
for(int i = 0; i < strlen(userinput); i++) {
userinput[i] = userinput[i] - userkey;
}
printf("the decrypted message is %s", userinput);
return 0;
}