This repository has been archived by the owner on Oct 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_menu.cpp
129 lines (119 loc) · 2.62 KB
/
sub_menu.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "sub_menu.h"
#include <filesystem>
#include "utils.h"
using namespace std;
void Menu_1(FAT32 *fat) {
size_t size_Mb;
string VolName;
cout << "enter size of Volume: ";
cin >> size_Mb;
Flush(std::cin);
cout << "enter Volume Name: ";
getline(cin, VolName);
fat = new FAT32(size_Mb, VolName);
cout << "Create Volume success" << endl;
Menu_sub(fat);
}
void Menu_2(FAT32 *fat) {
string VolName;
cout << "enter Volume Name: ";
getline(cin, VolName);
fat = new FAT32(VolName);
Menu_sub(fat);
}
void MenuImport(FAT32 *fat) {
std::string fPath;
std::cout << "File to import: ";
std::getline(std::cin, fPath);
fat->RootWrite(std::filesystem::path(fPath));
}
void Menu_sub(FAT32 *fat) {
string cmd;
bool run = true;
while (run) {
cout << "/";
getline(cin, cmd);
if (cmd == "import") {
MenuImport(fat);
}
if (cmd == "ls") {
Menu_showFile(fat);
}
if (cmd == "rm") {
}
if (cmd == "pass") {
}
if (cmd == "export") {
}
if (cmd == "cd") {
}
if (cmd == "exit") {
run = false;
}
}
}
void Menu_showFile(FAT32 *f) {
/*string imgPath;
cout<<"enter name Volume: ";
getline(cin,imgPath);
FAT32 f=FAT32(imgPath)*/
std::vector<int> root = f->ReadRoot();
f->printRoot(root);
}
void Menu_Password() {
string fileName;
string password;
bool change = false;
cout << "enter name of file need password\n";
getline(cin, fileName);
// TODO
// tìm đc file
// check đã từng có mật khẩu?
// nếu có
cout << "enter your password: ";
password = read_pass(cin);
cout << "do you want to change Password? (1.yes/0.no)";
cin >> change;
if (change) {
change_password(password);
uint8_t hash_pass = HashPassword(password);
}
}
string read_pass(istream &fi) {
string pass("");
char ch;
while ((ch = _getch()) != 13) // 13 is enter, input enter = done
{
if (ch != 8) {
pass.push_back(ch);
cout << '*';
} else if (pass.length() > 0) {
pass.pop_back();
cout << "\b \b";
}
}
cout << endl;
return pass;
}
void change_password(string password) {
string pass("");
cout << "Enter new password: ";
pass = read_pass(cin);
password = pass;
cout << "Your password has been reset successfully!\n";
system("pause");
}
uint8_t HashPassword(std::string const &Combine) {
uint8_t hash[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const uint8_t VALUE = Combine.length();
int j = 0;
for (auto Letter : Combine) {
srand(VALUE * Letter);
hash[j++] = 33 + rand() % 92;
}
/*for (int i = 0; i < 10; i++)
{
cout << hash[i];
}*/
return hash[10];
}