-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
102 lines (80 loc) · 3.58 KB
/
Main.java
File metadata and controls
102 lines (80 loc) · 3.58 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import java.io.File;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Check if "Files" Folder exists in User Directory. This is important for Storing Files later on
// Get current working directory
String ordner = System.getProperty("user.dir");
// Build the path to the folder
File folder = new File(ordner + "/Files");
// Check if it exists and if not, create it
if (folder.exists() && folder.isDirectory()) {
} else {
// Print that Folder doesnt exist
System.out.println("Files folder does not exist!");
// Create folder in user.dir
new File(System.getProperty("user.dir") + File.separator + "Files").mkdirs();
// Info Print
System.out.println("Folder \"Files\" has been created at " + ordner + "\\Files");
System.out.println("All Files will be saved there.");
// Wait for 2 seconds to output isnt rushed
try {
Thread.sleep(2000); // wait for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// Create Scanner
Scanner Scanner1 = new Scanner(System.in);
// Print "RSA" ASCII Art
System.out.println(" __________ _________ _____ ");
System.out.println(" \\______ \\/ _____/ / _ \\ ");
System.out.println(" | _/\\_____ \\ / /_\\ \\ ");
System.out.println(" | | \\/ \\/ | \\ ");
System.out.println(" |____|_ /_______ /\\____|__ /");
System.out.println(" \\/ \\/ \\/ ");
// Wait a second so Art is displayed in Terminal
try {
Thread.sleep(1000); // wait for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
// Welcome Print
System.out.println("----------------------------------------");
System.out.println(" Welcome to the RSA Encryptor!");
// Wait again for 2 Seconds
try {
Thread.sleep(2000); // wait for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
// Create Boolean to enable Main Menu Loop
boolean running = true;
//Open Main Menu Loop
while (running) {
// Open Main Menu Options
System.out.println("----------------------------------------");
System.out.println("What do you want to do?");
System.out.println("1) Generate RSA key pair");
System.out.println("2) Create a message ");
System.out.println("3) Encrypt a message ");
System.out.println("4) Decrypt a message");
System.out.println("----------------------------------------");
// Choose Menu Number / What to do
System.out.print("Please enter the corresponding menu number: ");
int choose = Scanner1.nextInt();
// If-clause to open the function the user chooses / throw arrow for invalid input
if (choose == 1) {
KeyGen.main(new String[]{});
} else if (choose == 2) {
CreateMessage.main(new String[]{});
} else if (choose == 3) {
EncryptMessage.main(new String[]{});
} else if (choose == 4) {
DecryptMessage.main(new String[]{});
} else {
System.out.println("Invalid option. Please try again.");
}
}
}
}