-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
86 lines (85 loc) · 2.07 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "aes.h"
#include "user.h"
int main()
{
int choice;
char username[MAX_USERNAME_LEN];
char password[MAX_PASSWORD_LEN];
unsigned char user_key[17];
// detail menu
while (1)
{
printf("1. regeist\n");
printf("2. login\n");
printf("3. exit\n");
printf("pleasr choice: ");
scanf("%d", &choice);
if (choice == 1)
{
if (register_user())
{
printf("register success\n");
}
else
{
printf("register failed\n");
}
}
else if (choice == 2)
{
if (login(username, password))
{
printf("login success\n");
break;
}
else
{
printf("login failed\n");
}
}
else if (choice == 3)
{
return 0;
}
else
{
printf("Parameter input error\n");
}
}
printf("1. encrypto file\n");
printf("2. decrypto file\n");
printf("3. exit\n");
scanf("%d", &choice);
if (choice == 1)
{
printf("username: %s\n", username);
printf("please input input file path\n");
char input_file[100];
scanf("%s", input_file);
printf("please input output file path\n");
char output_file[100];
scanf("%s", output_file);
generate_aes_key(username, password, user_key);
encrypt_file(user_key, input_file, output_file);
}
else if (choice == 2)
{
printf("username: %s\n", username);
printf("please input input file path\n");
char input_file[100];
scanf("%s", input_file);
printf("please input output file path\n");
char output_file[100];
scanf("%s", output_file);
generate_aes_key(username, password, user_key);
decrypt_file(user_key, input_file, output_file);
}
else if (choice == 3)
{
return 0;
}
else
{
printf("Parameter input error\n");
}
}