// Numbas version: finer_feedback_settings {"name": "Vigen\u00e8re Cipher encryption/decryption", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Vigen\u00e8re Cipher encryption/decryption", "tags": [], "metadata": {"description": "
A straightforward test of encrypting and decrypting an eight-letter message with the Vigenère Cipher using a four-letter key. Message letters are generated uniformly at random from the English alphabet, as are the key letters. 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 Vigenère Cipher.
", "advice": "a) We convert each letter into an element of $\\mathbb{Z}_{26}$, so {message} becomes {numbermessage}. Similarly we convert the key {key} to {numberkey}. To encrypt the first four message numbers we add the corresponding key numbers, working modulo 26 so we obtain $[\\var{numbermessage[0]}+\\var{numberkey[0]},\\var{numbermessage[1]}+\\var{numberkey[1]},\\var{numbermessage[2]}+\\var{numberkey[2]},\\var{numbermessage[3]}+\\var{numberkey[3]}]$ $\\equiv\\var{map(mod(numbermessage[i]+numberkey[i],26),i,0..3)}$.
\nTo encrypt the next four message numbers we then repeat that sequence of key numbers, which gives $[\\var{numbermessage[4]}+\\var{numberkey[0]},\\var{numbermessage[5]}+\\var{numberkey[1]},\\var{numbermessage[6]}+\\var{numberkey[2]}, \\var{numbermessage[7]}+\\var{numberkey[3]}]\\equiv\\var{map(mod(numbermessage[i]+numberkey[i-4],26),i,4..7)}$.
\nb) Similarly we convert the ciphertext {ciphertext} into numerical form {numberciphertext}. To decrypt we now subtract the elements of {numberkey} from each element of the ciphertext in turn, again working modulo 26. We obtain $[\\var{numberciphertext[0]}-\\var{numberkey[0]},\\var{numberciphertext[1]}-\\var{numberkey[1]},\\var{numberciphertext[2]}-\\var{numberkey[2]},\\var{numberciphertext[3]}-\\var{numberkey[3]},\\var{numberciphertext[4]}-\\var{numberkey[0]},$$\\var{numberciphertext[5]}-\\var{numberkey[1]},\\var{numberciphertext[6]}-\\var{numberkey[2]},\\var{numberciphertext[7]}-\\var{numberkey[3]}]\\equiv\\var{map(mod(numberciphertext[i]-numberkey[mod(i,4)],26),i,0..7)}$.
", "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}, "numbermessage": {"name": "numbermessage", "group": "Ungrouped variables", "definition": "Repeat(Random(0..25),8)", "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}, "numberkey": {"name": "numberkey", "group": "Ungrouped variables", "definition": "Repeat(Random(0..25),4)", "description": "", "templateType": "anything", "can_override": false}, "key": {"name": "key", "group": "Ungrouped variables", "definition": "join(map(alphabet[x],x,numberkey),\"\")", "description": "", "templateType": "anything", "can_override": false}, "ciphertext": {"name": "ciphertext", "group": "Ungrouped variables", "definition": "join(map(alphabet[x],x,numberciphertext),\"\")", "description": "", "templateType": "anything", "can_override": false}, "numberciphertext": {"name": "numberciphertext", "group": "Ungrouped variables", "definition": "Repeat(Random(0..25),8)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["alphabet", "numbermessage", "message", "numberkey", "key", "ciphertext", "numberciphertext"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": "2", "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]+numberkey[mod(i,4)],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": "2", "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(numberciphertext[i]-numberkey[mod(i,4)],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", "type": "question", "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/"}]}