Cyber security · GCSE · OCR J277 1.4.2, AQA 8525 3.6.3, Edexcel 1CP2 4.2.1 · about 25 min
Authenticate with a password, decrypt an encrypted command, and act on it.
[1 mark]Why does the robot authenticate before taking a command?
[1 mark]Why is the command encrypted?
[1 mark]A listener hears the Base's encrypted reply, KTWBFWI 25. What can they read without the key?
[1 mark]Authentication and encryption together protect against what?
[1 mark]If the wrong password is sent, what should the robot do?
Authenticate with the Base using the password bugbot42, decrypt its reply with a Caesar cipher (key 5), and carry out the FORWARD <cm> command to reach the green depot, without collisions. Do not send any command before the password, and do not type the distance: read it from the decrypted message. The caesar helper is provided.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
def caesar(text, key):
out = ""
for ch in text:
if ch.isalpha():
base = ord("A")
out = out + chr((ord(ch.upper()) - base + key) % 26 + base)
else:
out = out + ch
return out
def ask(question, seconds=1.5):
send(question)
for tick in range(int(seconds * 10)):
wait(0.1)
for sender, text in messages():
return text
return NonePlan your program here, then type it in and press Run.
KTWBFWI 25: what can they read without the key? (Look at what the Caesar cipher leaves alone.) And what did they learn when your robot sent the password?