Lab 1: Message Decryptor
Problem 1
Good evening, Detective! You are on a top-secret case and need to send encrypted messages to your partner. However, the instructions to your encryption machine were destroyed years ago, and it’s up to you to figure out how it works!
The encryptor machine has 10 black box functions that each encrypt a string in a various way. Your first task is to test various inputs and figure out how each function encrypts text.
Once you have an idea of what an encryption function does, write your own version of the function that encrypts a string in the same manner and run it through the checks in the support file. If all checks pass, then you’ve successfully built an encryptor for covert communications!
Instructions
Include this at the top of your program:
import shared-gdrive("lab1-support.arr", "1VQZFrXZdioyD8fv6qSigjvMSC-tiHbUn") as support
Now you will be able to access all of the encryptors and their testers in your pyret file.
The encryptor functions are named
support.encryptor1,
support.encryptor2,
support.encryptor3,
support.encryptor4,
...
support.encryptor10
The encryptor functions take in strings as input (e.g: support.encryptor1("mystery")
) and produce an encrypted result.
Note: Please keep a record of what strings you use to test each encryptor – you should be prepared to explain your choice of strings to a TA.
The tester functions are named, inspiringly,
support.test-encryptor1,
support.test-encryptor2,
support.test-encryptor3,
support.test-encryptor4,
...
support.test-encryptor10
To use them, you must use the name of your function as an input. For example, if you wrote the function:
fun my-cool-encryptor(str :: String) -> String:
# some code here
end
You would test whether it is correct by running:
support.test-encryptor1(my-cool-encryptor)
Hint: The encryptors are composed of functions from the Pyret strings library. Start out by reading through it.
CHECKPOINT:
Call over a TA after you have finished: encryptor4, encryptor7, and encryptor10.
Problem 2
Oh no – you just received word that a nefarious third party has broken your encryption scheme. It’s up to you to create new encryption functions for your machine that these mysterious crooks won’t be able to figure out but your partner will still understand.
Instructions
In a new document, write your own encryptor function. Call it new-encryptor
. It must take in a single string and produce some output. You may use any combination of functions from the Pyret strings library to build your function.
Once you’re done, press the “Publish” button in the Pyret Code Editor and trade links with another group and try to crack each other’s encryptors. Use the same format that you used to import support.arr
– call over a TA if you get stuck.
Write a function called new-decryptor
that takes in the output of the other group’s new-encryptor
and decrypts it. When you think your decryptor works, consult with the other group.
CHECKPOINT:
Call over a TA once both groups have solved each other’s encryptors.
Problem 3
After building such a great encryptor, you realize that you forgot something! Your encryptor doesn’t disguise or change sequences of numbers. This could be important if you ever want to covertly send phone numbers or credit card information to your partner.
Similarly to problem 2, write another encryptor function called new-number-encryptor
. This function should take in a number and produce some output. You may use any combination of functions from the Pyret numbers library.
Just like with new-encryptor
, press the “Publish” button in the Pyret Code Editor and trade links with another group and try to crack each other’s encryptors. Use the same format that you used to import support.arr – call over a TA if you get stuck.
Write a function called new-number-decryptor
that takes in the output of the other group’s new-number-encryptor
and decrypts it. When you think your decryptor works, consult with the other group.
CHECKPOINT:
Call over a TA once both groups have solved each other’s number encryptors.
Success!
Your new encryptor functions worked! You can send secure messages to your partner without worrying about leaking the details of your latest case.
Lab 1: Message Decryptor
Problem 1
Good evening, Detective! You are on a top-secret case and need to send encrypted messages to your partner. However, the instructions to your encryption machine were destroyed years ago, and it’s up to you to figure out how it works!
The encryptor machine has 10 black box functions that each encrypt a string in a various way. Your first task is to test various inputs and figure out how each function encrypts text.
Once you have an idea of what an encryption function does, write your own version of the function that encrypts a string in the same manner and run it through the checks in the support file. If all checks pass, then you’ve successfully built an encryptor for covert communications!
Instructions
Include this at the top of your program:
import shared-gdrive("lab1-support.arr", "1VQZFrXZdioyD8fv6qSigjvMSC-tiHbUn") as support
Now you will be able to access all of the encryptors and their testers in your pyret file.
The encryptor functions are named
The encryptor functions take in strings as input (e.g:
support.encryptor1("mystery")
) and produce an encrypted result.Note: Please keep a record of what strings you use to test each encryptor – you should be prepared to explain your choice of strings to a TA.
The tester functions are named, inspiringly,
To use them, you must use the name of your function as an input. For example, if you wrote the function:
You would test whether it is correct by running:
Hint: The encryptors are composed of functions from the Pyret strings library. Start out by reading through it.
CHECKPOINT:
Call over a TA after you have finished: encryptor4, encryptor7, and encryptor10.
Problem 2
Oh no – you just received word that a nefarious third party has broken your encryption scheme. It’s up to you to create new encryption functions for your machine that these mysterious crooks won’t be able to figure out but your partner will still understand.
Instructions
In a new document, write your own encryptor function. Call it
new-encryptor
. It must take in a single string and produce some output. You may use any combination of functions from the Pyret strings library to build your function.Once you’re done, press the “Publish” button in the Pyret Code Editor and trade links with another group and try to crack each other’s encryptors. Use the same format that you used to import
support.arr
– call over a TA if you get stuck.Write a function called
new-decryptor
that takes in the output of the other group’snew-encryptor
and decrypts it. When you think your decryptor works, consult with the other group.CHECKPOINT:
Call over a TA once both groups have solved each other’s encryptors.
Problem 3
After building such a great encryptor, you realize that you forgot something! Your encryptor doesn’t disguise or change sequences of numbers. This could be important if you ever want to covertly send phone numbers or credit card information to your partner.
Similarly to problem 2, write another encryptor function called
new-number-encryptor
. This function should take in a number and produce some output. You may use any combination of functions from the Pyret numbers library.Just like with
new-encryptor
, press the “Publish” button in the Pyret Code Editor and trade links with another group and try to crack each other’s encryptors. Use the same format that you used to import support.arr – call over a TA if you get stuck.Write a function called
new-number-decryptor
that takes in the output of the other group’snew-number-encryptor
and decrypts it. When you think your decryptor works, consult with the other group.CHECKPOINT:
Call over a TA once both groups have solved each other’s number encryptors.
Success!
Your new encryptor functions worked! You can send secure messages to your partner without worrying about leaking the details of your latest case.