|
1 | 1 | import java.io.Console;
|
2 | 2 |
|
3 | 3 | 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 |
4 | 8 | public static void main(String[] args){
|
5 | 9 | 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 | + String message = myConsole.readLine(BLUE+"encryptedMessage"+GREEN+"@caesar:"+BLUE+"~$ "+NEUTRAL); |
| 44 | + System.out.println("\nEnter the shift key '1 - 25' :"); |
| 45 | + int key = Integer.parseInt(myConsole.readLine(BLUE+"key"+GREEN+"@caesar:"+BLUE+"~$ "+NEUTRAL)); |
| 46 | + myCaesar.setKey(key); |
| 47 | + myCaesar.decrypt(message); |
| 48 | + System.out.println(RED+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"+NEUTRAL); |
| 49 | + System.out.println(BLUE+"Input String: "+GREEN+message); |
| 50 | + System.out.println(BLUE+"Decrypted String: "+GREEN+myCaesar.getDecryptedMsg()); |
| 51 | + System.out.println(BLUE+"Shift/Decryption key : "+GREEN+myCaesar.getKey()+NEUTRAL); |
| 52 | + System.out.println(RED+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"+NEUTRAL); |
| 53 | + |
| 54 | + }else if(option == 3){ |
| 55 | + System.out.println(RED+"Goodbye :)"); |
| 56 | + running = false ; |
| 57 | + }else { |
| 58 | + System.out.println(RED+"Oops!, invalid Option :("+NEUTRAL); |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + // |
| 63 | +// int |
| 64 | +// CaesarShift encDec = new CaesarShift("Hello",25); |
| 65 | +// System.out.println("Input String: " + input); |
| 66 | +// System.out.println("Encrypted: " + encDec.encrypt(input)); |
| 67 | +// System.out.println("Decrypted String: "+encDec.decrypt(encDec.encrypt(input))); |
12 | 68 | }
|
13 | 69 | }
|
0 commit comments