-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunner.java
More file actions
48 lines (44 loc) · 1.98 KB
/
Runner.java
File metadata and controls
48 lines (44 loc) · 1.98 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
import java.util.Scanner;
public class Runner {
public static void main(String[] args) {
System.out.println("Choose what you would like to do with the file:\n1. Encrypt\n2. Decrypt");
Scanner scan = new Scanner(System.in);
int choice = scan.nextInt();
while (choice != 1 && choice != 2) {
System.out.println("Please repeat your request. I remind:\n1. Encrypt\n2. Decrypt");
choice = scan.nextInt();
}
if (choice == 1) {
System.out.println("Select key (from 1 to 20)");
int key = scan.nextInt();
while (1 > key || key > 20) {
System.out.println("Please repeat your request. I remind:\nSelect key (from 1 to 20)");
key = scan.nextInt();
}
Encryption.encryption(key);
System.out.printf("Encryption completed, file named %s", Encryption.pathDestination);
} else if (choice == 2) {
scan.nextLine();
System.out.println("If you know the key please write: y or n");
String knowKey = scan.nextLine();
while (!knowKey.equals("y") && !knowKey.equals("n")) {
System.out.println("Please repeat your request. I remind:\nIf you know the key please write: y or n");
knowKey = scan.nextLine();
}
if (knowKey.equals("y")) {
System.out.println("Enter the key");
int key = scan.nextInt();
while (1 > key || key > 20) {
System.out.println("Please, enter the key");
key = scan.nextInt();
}
Decoding.decoding(key);
} else if (knowKey.equals("n")) {
Decoding.brutForce();
}
System.out.printf("Decoding completed, file named %s", Decoding.pathDestination);
} else {
System.out.println("Please repeat your request. I remind:\n1. Encrypt\n2. Decrypt");
}
}
}