-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLicenseKeyMenuApp.java
More file actions
109 lines (87 loc) · 7.03 KB
/
Copy pathLicenseKeyMenuApp.java
File metadata and controls
109 lines (87 loc) · 7.03 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
103
104
105
106
107
108
109
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
public class LicenseKeyMenuApp {
final static LicenseManager licenseManager = new LicenseManager();;
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
boolean running = true;
System.out.println(" ███████████ █████ ███ █████ █████████ █████████ █████ ███ █████ ████ \r\n" + //
"░░███░░░░░███░░███ ░███ ░░███ ███░░░░░███ ███░░░░░███ ░░███ ░░░ ░░███ ███░ \r\n" + //
" ░███ ░███ ░███ ░███ ░███ ░███ ░░░ ░███ ░░░ ░███ ████ ██████ ██████ ████████ █████ ██████ ░███ ███ ██████ █████ ████\r\n" + //
" ░██████████ ░███ ░███ ░███ ░░█████████ ░░█████████ ░███ ░░███ ███░░███ ███░░███░░███░░███ ███░░ ███░░███ ░███████ ███░░███░░███ ░███ \r\n" + //
" ░███░░░░░░ ░░███ █████ ███ ░░░░░░░░███ ░░░░░░░░███ ░███ ░███ ░███ ░░░ ░███████ ░███ ░███ ░░█████ ░███████ ░███░░███ ░███████ ░███ ░███ \r\n" + //
" ░███ ░░░█████░█████░ ███ ░███ ███ ░███ ░███ █ ░███ ░███ ███░███░░░ ░███ ░███ ░░░░███░███░░░ ░███ ░░███ ░███░░░ ░███ ░███ \r\n" + //
" █████ ░░███ ░░███ ░░█████████ ░░█████████ ███████████ █████░░██████ ░░██████ ████ █████ ██████ ░░██████ █████ ░░████░░██████ ░░███████ \r\n" + //
"░░░░░ ░░░ ░░░ ░░░░░░░░░ ░░░░░░░░░ ░░░░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░ ░░░░ ░░░░░░ ░░░░░███ \r\n" + //
" ███ ░███ \r\n" + //
" ░░██████ \r\n" + //
" ░░░░░░ ");
while (running) {
System.out.println("\n--- PWSS License Key Generator ---");
System.out.println("1. Create new License Key (human readable)");
System.out.println("2. Create Finalized License Key");
System.out.println("3. Convert Finalized Key Into License Key");
System.out.println("4. Create new Secret key");
System.out.println("5. Exit");
System.out.print("Please select an option: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1:
createNewLicenseKey(scanner);
break;
case 2:
createFinalizedLicenseKey(scanner);
break;
case 3:
convertFinalizedKeyToLicenseKey(scanner);
break;
case 4:
createNewSecretKey();
break;
case 5:
running = false;
System.out.println("Exiting the application. Goodbye!");
break;
default:
System.out.println("Invalid option. Please try again.");
}
// Pause execution before showing menu again
pause(scanner);
}
scanner.close();
}
private static void createNewLicenseKey(Scanner scanner) throws NoSuchAlgorithmException {
System.out.println("Creating new License Key (human readable)...");
System.out.print("Please enter pro or user: ");
String input = scanner.nextLine();
LicenseKeyGenerator licenseKeyGenerator = new LicenseKeyGenerator();
if(input.equalsIgnoreCase("pro"))
licenseKeyGenerator.generateLicenseKeyForProUser();
else
licenseKeyGenerator.generateLicenseKeyForUser();
}
private static void createFinalizedLicenseKey(Scanner scanner) throws Exception {
System.out.print("Please enter the key from option 1: ");
String input = scanner.nextLine();
System.out.println("Creating finalized License Key with input: " + input);
licenseManager.createFinalizedLicenceKeyFromHumanReadAbleKey(input);
}
private static void convertFinalizedKeyToLicenseKey(Scanner scanner) throws Exception {
System.out.print("Please enter the Finalized Key to convert: ");
String input = scanner.nextLine();
System.out.println("Converting Finalized Key to License Key...");
licenseManager.convertFinalizedKeyIntoHumanReadAbleLicenceKey(input);
}
/**
* Pauses execution until the user presses Enter.
*/
private static void pause(Scanner scanner) {
System.out.print("\nPress Enter to continue...");
scanner.nextLine(); // Wait for user input
}
private static final void createNewSecretKey() {
System.out.println("Creating new Secret Key...");
licenseManager.createNewSecretKeyFile();
}
}