Chapter 18. Intercepting Guard Conversations
During the final phase of our plan, Rich and Pedro will stay a bit more behind, and I’ll move ahead to take care of opening the door. I have very clear instructions, so I don’t think there will be any problems.
Evidently, Bud and Pedro have much more programming skill. In theory, they should be the ones to open the door, but they’ll be in charge of another equally important function: controlling the guards’ communications and monitoring the cameras.
During the escape, Pedro will need to access one of the control posts in the main hallway. Remember that these posts are only occupied during the day. At night, it’s not necessary for anyone to be watching, so the idea is to use the computer there to monitor all the prison cameras. This way, we’ll know if someone is approaching.

To be even more certain that no one discovers us, Bud will be next to me and will be in charge of two things. Controlling the internal communication of the guards and, at the same time, communicating with Pedro. This way, if Pedro sees something suspicious, he can alert Bud, and Bud can alert me, so we can return to our cells or hide.
Things are not always simple, and in this case, everything gets complicated. The problem is that all incoming and outgoing communications from Bud’s computer are monitored. It’s not a normal computer; let’s remember that Bud is a prisoner; he has many restrictions and is not allowed to communicate with people from the outside.
So, to communicate among ourselves, we had no choice but to create an encoded messaging system. The idea is to replace each letter with symbols. This way, the messages will be completely impossible to read if you don’t know how to decode them. To avoid even more suspicion, we’ll only send messages if it’s absolutely necessary. Even if the guards start to suspect something, by the time they realize it, we’ll have already finished.
Once we get out, we’ll have approximately three hours until the room inspection. Therefore, I must hurry. It will take me about 30 minutes to reach Pedro’s friend’s house. From there, I’ll need another 15 minutes to get to the library. After the meeting with Chani and Rich, I’ll need another 15 minutes to get to the parking lot where I’ll meet Phil. Then, it will take me between 15 and 30 minutes to return to the prison and, possibly, another 15 to 30 minutes to get to my cell, as I might have to hide and wait for there to be no guards around.
This adds up to a total of between 1 hour and 45 minutes and 2 hours. Considering possible setbacks, I calculate an additional 15-minute margin, making a total of 2 hours and 15 minutes. Therefore, the meeting should last approximately half an hour. Chani’s cousin already knows my itinerary and the time I have, so I guess he’ll have everything planned according to that. It seems like everything is going as we had planned, so I’m quite calm. Now let’s review together that the programs for encrypting and decrypting messages work.
Exercise 1. Create a program to encode text entered via keyboard, replacing all lowercase letters with specific symbols defined. It will work in a loop that will process multiple messages.
Solution:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("Enter the text to encode (or type 'exit' to finish):");
String text = scanner.nextLine();
if (text.equalsIgnoreCase("exit")) {
break;
}
String encodedText = text.replace('a', '!')
.replace('b', '@')
.replace('c', '#')
.replace('d', '$')
.replace('e', '%')
.replace('f', '^')
.replace('g', '&')
.replace('h', '*')
.replace('i', '(')
.replace('j', ')')
.replace('k', '-')
.replace('l', '_')
.replace('m', '=')
.replace('n', '+')
.replace('o', '[')
.replace('p', ']')
.replace('q', '{')
.replace('r', '}')
.replace('s', ';')
.replace('t', ':')
.replace('u', '<')
.replace('v', '>')
.replace('w', ',')
.replace('x', '.')
.replace('y', '?')
.replace('z', '/');
System.out.println("Encoded text: " + encodedText);
}
}
}
Exercise 2. Create a program to decode the previously encoded text, replacing the symbols with the original lowercase letters. It will work in a loop to process multiple messages.
Solution:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("Enter the text to decode (or type 'exit' to finish):");
String encodedText = scanner.nextLine();
if (encodedText.equalsIgnoreCase("exit")) {
break;
}
String decodedText = encodedText.replace('!', 'a')
.replace('@', 'b')
.replace('#', 'c')
.replace('$', 'd')
.replace('%', 'e')
.replace('^', 'f')
.replace('&', 'g')
.replace('*', 'h')
.replace('(', 'i')
.replace(')', 'j')
.replace('-', 'k')
.replace('_', 'l')
.replace('=', 'm')
.replace('+', 'n')
.replace('[', 'o')
.replace(']', 'p')
.replace('{', 'q')
.replace('}', 'r')
.replace(';', 's')
.replace(':', 't')
.replace('<', 'u')
.replace('>', 'v')
.replace(',', 'w')
.replace('.', 'x')
.replace('?', 'y')
.replace('/', 'z');
System.out.println("Decoded text: " + decodedText);
}
}
}