-
Notifications
You must be signed in to change notification settings - Fork 0
/
encrypt.c
71 lines (71 loc) · 1.27 KB
/
encrypt.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
62
63
64
65
66
67
68
69
70
71
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char str[100];
int i=0;
printf("********SECURITY ENCRYPTION********\n");
printf("\nEnter the password : ");
do
{
str[i]=getch();
i++;
}while(str[i-1]!='\r');
str[i-1]='\0';
if(strcmp(str,"dodgy254")==0)
start();
else
printf("\nWrong password!!!\n\n\n");
}
void start()
{
int n;
printf("\n1) Enrypt\n2) Decrypt\n3) Exit\n");
scanf("%d",&n);
fflush(stdin);
if(n==1)
encrypt();
else if(n==2)
decrypt();
else
exit(0);
}
void encrypt()
{
char str[100];
int i,j,k;
int num[100];
printf("Enter the string : ");
gets(str);
for(i=0;str[i]!='\0';i++)
num[i]=(int)str[i]+32;
printf("Code is : ");
for(j=0;j<i;j++)
printf("%d ",num[j]);
printf("5493");
printf("\n\n\n");
start();
}
void decrypt()
{
char str[100],ch;
int i=0,j,k,n;
int num[100];
printf("Enter the code : ");
while(num[i-1]!=5493)
{
scanf("%d",&num[i]);
i++;
}
i--;
n=i;
for(i=0;i<n;i++)
{
str[i]=num[i]-32;
}
for(j=0;j<n;j++)
printf("%c",str[j]);
printf("\n\n\n");
start();
}