Chapter 18. Intercepting Guard Conversations
During the last phase of our plan, Rich and Pedro will stay a bit behind, and I’ll go ahead to take care of opening the door. I have very clear Instructions, so I don’t think there will be any problem.
Obviously, Bud and Pedro have much more Programming skill. In theory, they should be in charge of opening the door, but they will take care 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 there’s no need 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 anyone is approaching.

To be even more certain that no one discovers us, Bud will be with 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 warn Bud, and Bud can warn me, so we can return to our cells or hide.
Things aren’t 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; remember that Bud is a prisoner; he has many restricted options and is not allowed to communicate with people from outside.
So, to communicate among ourselves, we’ve had no choice but to create a coded message system. The idea is to replace each letter with symbols. This way, the messages will be totally impossible to read if you don’t know how to decipher them. To avoid even more suspicion, we’ll only send messages if it’s absolutely necessary. Even if the guards become suspicious, by the time they realize it we’ll have finished.
Once we get out, we’ll have approximately three hours until 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 reach the library. After the meeting with Chani and Rich, I’ll need another 15 minutes to reach 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 additional minutes to reach my cell, as I might have to hide and wait until there are no guards.
This adds up to a total of between 1 hour and 45 minutes and 2 hours. Considering possible setbacks, I calculate a margin of 15 additional minutes, 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 assume he will have everything planned according to that. It seems that everything is going as planned, so I’m quite calm. Now let’s review together that the Programs for encoding and decoding messages work.
Exercise 1. Create a Program to encode text entered from keyboard, replacing all lowercase letters with specific defined symbols. 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 text to encode (or type 'exit' to end):");
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 previously encoded text, replacing the symbols with the original lowercase letters. It will work in a loop to process multiple messages.
SoluciΓ³n:
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 text to decode (or type 'exit' to end):");
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);
}
}