ENGG1111 Computer Programming and Applications
Assignment 2 Deadline: 17:00 Nov 14, 2014.
CodeBreaker
Background
You and a group of colleagues meet up socially now and then at various shopping malls. The details of when and where to meet are sent out to the group in the form of text messages. To keep the details private, the messages are encoded so that they cannot be read easily; they must be decoded before they can be read.
Here is an example of an encoded message displayed as text:
Unfortunately, you lost the key needed to decode the latest message and don’t want to ask for it again.
Your task in this assignment is to write a program to break the code so that you can read a message without knowing the key.
You know certain details about the messages which will make it easier to write the codebreaker: o o
o
all messages are exactly 140 characters long; the decoded messages will contain the name of one shopping mall. Your group meets at only 7 malls, all of which have exactly 13 characters in their names:
- 1881 Heritage
- Festival Walk
- Horizon Plaza
- Langham Place
- Olympian City
- Pacific Place
- Telford Plaza the messages are encoded using a simple scheme involving character substitution.
Encoding
Messages are encoded using a form of Caesar cipher. A Caesar Cipher encodes a message by replacing each character with the character a certain number of positions from the original. For example, using the English alphabet and shifting by 4 positions to the right, the word LOST is encoded as PSWX:
...
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
...
...
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
...
4 position shift
The number used to specify the number of positions to shift during encoding is known as the key; in this example, the key is 4. Clearly, we can decode PSWX by shifting each character back 4 places to the left to recreate LOST.
The final issue is how to handle cases where the shift takes us beyond the last