// Numbas version: exam_results_page_options {"name": "Caesar Cipher encryption/decryption", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Caesar Cipher encryption/decryption", "tags": [], "metadata": {"description": "

A straightforward test of encrypting and decrypting an eight-letter message with the Caesar Cipher.  Message letters are generated uniformly at random from the English alphabet, as is the key.  Students are expected to be able to map English letters onto elements of $\\mathbb{Z}_{26}$ in the usual order.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

Suppose we wish to encrypt the (nonsense) plaintext {message} using the Caesar Cipher.

", "advice": "

a) We convert each letter into an element of $\\mathbb{Z}_{26}$, so {message} becomes {numbermessage}.  Then to perform the encryption we add {key} to each element of the message in turn, working modulo 26, so the answer becomes $[\\var{numbermessage[0]}+\\var{key},\\var{numbermessage[1]}+\\var{key},\\var{numbermessage[2]}+\\var{key},\\var{numbermessage[3]}+\\var{key},\\var{numbermessage[4]}+\\var{key},\\var{numbermessage[5]}+\\var{key},\\var{numbermessage[6]}+\\var{key},\\var{numbermessage[7]}+\\var{key}]\\equiv\\var{map(mod(numbermessage[i]+key,26),i,0..7)}$.

\n

b) This time {ciphertext} was already given in numerical form.  To decrypt we now subtract {key} from each element of the ciphertext in turn, again working modulo 26.  We obtain $[\\var{ciphertext[0]}-\\var{key},\\var{ciphertext[1]}-\\var{key},\\var{ciphertext[2]}-\\var{key},\\var{ciphertext[3]}-\\var{key},\\var{ciphertext[4]}-\\var{key},\\var{ciphertext[5]}-\\var{key},\\var{ciphertext[6]}-\\var{key},\\var{ciphertext[7]}-\\var{key}]\\equiv\\var{map(mod(ciphertext[i]-key,26),i,0..7)}$.

\n

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"alphabet": {"name": "alphabet", "group": "Ungrouped variables", "definition": "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"", "description": "", "templateType": "anything", "can_override": false}, "message": {"name": "message", "group": "Ungrouped variables", "definition": "join(map(alphabet[x],x,numbermessage),\"\")", "description": "", "templateType": "anything", "can_override": false}, "numbermessage": {"name": "numbermessage", "group": "Ungrouped variables", "definition": "Repeat(Random(0..25),8)", "description": "", "templateType": "anything", "can_override": false}, "key": {"name": "key", "group": "Ungrouped variables", "definition": "random(0 .. 25#1)", "description": "", "templateType": "randrange", "can_override": false}, "ciphertext": {"name": "ciphertext", "group": "Ungrouped variables", "definition": "Repeat(Random(0..25),8)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["alphabet", "message", "numbermessage", "key", "ciphertext"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Encrypt the plaintext using the key {key}.  (Express your answer as a sequence of elements of $\\mathbb{Z}_{26}$.)

", "correctAnswer": "matrix(map(mod(numbermessage[i]+key,26),i,0..7))", "correctAnswerFractions": false, "numRows": 1, "numColumns": "8", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0, "prefilledCells": ""}, {"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Decrypt the ciphertext {ciphertext} using the key {key}.

", "correctAnswer": "matrix(map(mod(ciphertext[i]-key,26),i,0..7))", "correctAnswerFractions": false, "numRows": 1, "numColumns": "8", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0, "prefilledCells": ""}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Maura Paterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7001/"}]}]}], "contributors": [{"name": "Maura Paterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7001/"}]}