forked from parakramgambhir14/CryptVault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (53 loc) · 1.93 KB
/
main.cpp
File metadata and controls
78 lines (53 loc) · 1.93 KB
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
#include <iostream>
// Core modules
#include "core/auth.h"
#include "core/vault.h"
// Security features
#include "security/security.h"
// Config (stores password, attempts, timestamp)
#include "utils/config.h"
using namespace std;
int main() {
// ================= LOAD CONFIG =================
// Loads:
// - stored password
// - failed attempts count
// - timestamp (for expiry feature)
loadConfig();
// ================= EXPIRY CHECK =================
// If vault lifetime exceeded → auto self-destruct
checkExpiry();
// ================= FIRST RUN SETUP =================
// If no password is stored → first time execution
if (isFirstRun()) {
firstRunSetup(); // asks user to set master password
}
// ================= LOGIN SYSTEM =================
// Returns:
// REAL_USER → correct password
// DECOY_USER → wrong password (trap mode)
// BLOCKED → too many attempts → destroy
LoginResult result = login();
// ================= SELF-DESTRUCT =================
// If max attempts reached → delete vault permanently
if (result == BLOCKED) {
destroyVault();
cout << "\n⚠️ SECURITY BREACH DETECTED\n";
cout << "Vault has been permanently destroyed.\n";
return 0; // terminate program
}
// ================= VAULT ACCESS =================
// Correct password → real vault
// Wrong password → decoy vault (attacker trap)
if (result == REAL_USER) {
cout << "\nAccess Granted: Real Vault\n";
// Loads and runs actual vault
startVault("data/vault.txt");
} else {
cout << "\nAccess Granted: Limited Mode\n";
// Loads decoy vault to mislead attacker
startVault("data/decoy.txt");
}
// ================= EXIT =================
return 0;
}