Skip to content

Commit 9507b11

Browse files
committed
Allow breaking Vigenere without brute force
1 parent 551bd9c commit 9507b11

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

trainingportal/qna.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ let caesarEnc = (mes, key) => {
7979
return getRes(mes, shifted);
8080
}
8181

82-
let vigenereEnc = (mes, key) => {
82+
let vigenereEnc = (m, key) => {
8383
let keyArray = [];
8484
let keyLen = 3;
85+
let mes = "LOREM " + m;
8586

8687
if(util.isNullOrUndefined(key)){
8788
for(let i = 0; i<keyLen; i++){

trainingportal/static/lessons/cryptoBreaker/definitions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name":"Vigenère Cipher",
1717
"description": "crypto_vigenere.md",
1818
"type":"quiz",
19-
"mission":"Decrypt the cipher below. As before, the plain text is in Latin.",
19+
"mission":"Decrypt the cipher below knowing that the first word is 'LOREM'.",
2020
"codeBlockIds":[]
2121
},
2222
{

trainingportal/test/qna.test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,14 @@ describe("qna", () => {
2121
let text = "PLAIN TEXT";
2222
for(let alg in qna.DEFS){
2323
if(alg === "crypto_analysis") continue;
24-
let res = qna.getCode(alg,text);
24+
let res = qna.getCode(alg,text);
25+
if(alg === "crypto_vigenere") text = "LOREM " + text;
2526
let check = qna.checkCode(text, res.digest);
2627
assert(check === true, `Validation failed for correct text using ${alg}`);
2728
}
2829
});
2930

3031

31-
test("vigenere should return plain text for 'AAA'",()=>{
32-
let text = "PLAIN TEXT";
33-
let expected = "BYOUA HQKH"
34-
let key = "MNO"
35-
let res = qna.getCode("crypto_vigenere",text,key);
36-
assert.strictEqual(res.code, expected, "Did not result in the same cipher for key: 'MNO'");
37-
38-
});
39-
4032
test("xorOp should return plain text for '0x0'",()=>{
4133
let text = "PLAIN TEXT";
4234
let expected = "50 4C 41 49 4E 20 54 45 58 54";

0 commit comments

Comments
 (0)