I have 2 programs using a process to communicate with each other. My program is meant to allow a user to encrypt any password from their history - however it is not allowing me to change the value of what I am trying to encrypt. I understand how the processes communicate, but for some reason changing the value is not working.
My history
public static int History(LinkedList<String> listy){
Scanner s = new Scanner(System.in);
int input;
String selection;
System.out.println("--------------------");
System.out.println(" History ");
for(int i = 0; i < listy.size(); i++){
System.out.println(i + ".) " + listy.get(i));
}
System.out.println("Please make a selection: ");
input = s.nextInt();
selection = listy.get(input);
System.out.println("--------------------");
return input;
}
Here is my encrypt:
String mode;
Scanner s = new Scanner(System.in);
String passkey = "";
//String answer = "";
mode = s.next();
String encryptedMsg = "";
while(!mode.equals("QUIT")){
if(mode.equals("PASSKEY")){
passkey = s.next();
passkey = passkey.toUpperCase();
encryptedMsg = encrypt(passkey);
}
if(mode.equals("ENCRYPT")){
System.out.println(encrypt(passkey) + " is the password encrypted");
}else if(mode.equals("DECRYPT")){
System.out.println(decrypt(encryptedMsg) + " is the password decrypted");
}
mode = s.next();
}
and here is my call to change the passkey being encrypted:
else if(mode.equals("ENCRYPT")){
toLogger.println("ENCRYPT");
String thisPasskey;
System.out.println("Would you like to see your password history? Enter (Y/N)");
mode = s.next();
if(mode.equals("Y")){
//History(listykenz);
System.out.println("Current passkey being encrypted...");
//thisPasskey = History(listykenz);
int index = History(listykenz);
System.out.println(listykenz.get(index));
toEncrypt.println(listykenz.get(index));
toEncrypt.flush();
toEncrypt.println("ENCRYPT");
toEncrypt.flush();
System.out.println(fromEncrypt.nextLine());
toEncrypt.flush();
toLogger.flush();
}else if(mode.equals("N")) {
System.out.println("Current passkey being encrypted...");
thisPasskey = listykenz.getLast();
System.out.println(thisPasskey);
toEncrypt.println(thisPasskey);
toEncrypt.println("ENCRYPT");
toEncrypt.flush();
System.out.println(fromEncrypt.nextLine());
toLogger.flush();
toEncrypt.flush();
}
toLogger.flush();
}
Thank you