Skip to content

Commit af4c8fd

Browse files
committed
add banner and beautify Encrypt UI
1 parent 49ba405 commit af4c8fd

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

src/main/java/App.java

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
11
import java.io.Console;
22

33
public class App {
4+
public static final String RED = "\033[0;31m"; // RED
5+
public static final String GREEN = "\033[0;32m"; // GREEN
6+
public static final String BLUE = "\033[0;34m"; // BLUE
7+
public static final String NEUTRAL = "\033[0m"; // NEUTRAL
48
public static void main(String[] args){
59
Console myConsole = System.console();
6-
System.out.println("Enter the text to Encrypt: ");
7-
String input = myConsole.readLine();
8-
CaesarShift encDec = new CaesarShift();
9-
System.out.println("Input String: " + input);
10-
System.out.println("Encrypted: " + encDec.encrypt(input));
11-
System.out.println("Decrypted String: "+encDec.decrypt(encDec.encrypt(input)));
10+
CaesarShift myCaesar = new CaesarShift();
11+
boolean running = true;
12+
String version = "V1.0";
13+
14+
System.out.println(BLUE+" ____ ____ _ _ __ _ \n" +
15+
" / ___|__ _ ___ ___ __ _ _ __/ ___|| |__ (_)/ _| |_ \n" +
16+
"| | / _` |/ _ \\/ __|/ _` | '__\\___ \\| '_ \\| | |_| __|\n" +
17+
"| |__| (_| | __/\\__ \\ (_| | | ___) | | | | | _| |_ \n" +
18+
" \\____\\__,_|\\___||___/\\__,_|_| |____/|_| |_|_|_| \\__|"+version+NEUTRAL);
19+
System.out.println(RED+" Encrypt/Decrypt your messages"+NEUTRAL);
20+
System.out.println(BLUE+" By @Chal13W1zz"+NEUTRAL);
21+
22+
while (running){
23+
24+
System.out.println("\n \nSelect an option \n -> Encrypt a message : 1 \n -> Decrypt a message : 2 \n -> Exit : 3 ");
25+
Integer option = Integer.parseInt(myConsole.readLine(BLUE+"option"+GREEN+"@caesar:"+BLUE+"~$ "+NEUTRAL));
26+
27+
28+
if(option == 1){
29+
System.out.println("\nEnter the message to Encrypt : ");
30+
String message = myConsole.readLine(BLUE+"message"+GREEN+"@caesar:"+BLUE+"~$ "+NEUTRAL);
31+
System.out.println("\nEnter the shift key '1 - 25' :");
32+
int key = Integer.parseInt(myConsole.readLine(BLUE+"key"+GREEN+"@caesar:"+BLUE+"~$ "+NEUTRAL));
33+
myCaesar.setKey(key);
34+
myCaesar.encrypt(message);
35+
System.out.println(RED+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"+NEUTRAL);
36+
System.out.println(BLUE+"Input String: "+GREEN+message);
37+
System.out.println(BLUE+"Encrypted String: "+GREEN+myCaesar.getEncryptedMsg());
38+
System.out.println(BLUE+"Shift/Encryption key : "+GREEN+myCaesar.getKey()+NEUTRAL);
39+
System.out.println(RED+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"+NEUTRAL);
40+
41+
}else if(option == 2){
42+
System.out.println("Enter the message to Decrypt : ");
43+
44+
}else if(option == 3){
45+
System.out.println("Goodbye :)");
46+
running = false ;
47+
}else {
48+
System.out.println(RED+"Oops!, invalid Option :("+NEUTRAL);
49+
}
50+
}
51+
52+
//
53+
// int
54+
// CaesarShift encDec = new CaesarShift("Hello",25);
55+
// System.out.println("Input String: " + input);
56+
// System.out.println("Encrypted: " + encDec.encrypt(input));
57+
// System.out.println("Decrypted String: "+encDec.decrypt(encDec.encrypt(input)));
1258
}
1359
}

0 commit comments

Comments
 (0)