public void decrypting() { String cipherString; char cipherChar; int padInt = 0; char plainChar; String newS = ""; while (decrypt.hasNextLine()) { cipherString = decrypt.nextLine(); for (int i = 0; i < cipherString.length(); i++) { cipherChar = cipherString.charAt(i); System.out.print(cipherChar); try { padInt = pad.read(); } catch (Exception e) { System.out.println(e.getMessage()); } plainChar = (char) ((cipherChar - padInt + 128) % 128); newS = newS + plainChar; } } System.out.println(""); System.out.println("Output (plaintext): "); System.out.println(newS); try { pad.reset(); } catch (Exception e) { System.out.println(e.getMessage()); } }