-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
61 lines (49 loc) · 1.32 KB
/
Main.java
File metadata and controls
61 lines (49 loc) · 1.32 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
package CryptMachine;
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
/*char a = ':';
char b = (char)(a+10);
System.out.println(b);
System.out.println((char)(b-10));*/
String path;
System.out.println("Please enter file path");
Scanner filePath = new Scanner(System.in);
while (filePath.hasNext()) {
path = filePath.next();
File temp = new File(path);
if(temp.exists()) {
Machine mach = Machine.getInstance(path);
System.out.println("Please choose encrypt or decrypt your file (e/d)?");
Scanner work = new Scanner(System.in);
while(work.hasNext()) {
String comand = work.next().toLowerCase();
while (!(comand.equals("e") || comand.equals("d"))) {
System.out.println("Please enter correct variant: e or d");
Scanner updateWork = new Scanner(System.in);
if(updateWork.hasNext()) {
comand = updateWork.next().toLowerCase();
updateWork.close();
}
}
if (comand.equals("e")) {
mach.encrypt();
break;
}
else if (comand.equals("d")) {
mach.decrypt();
break;
}
}
work.close();
}
else {
System.out.println("File not found");
break;
}
}
filePath.close();
}
}