Skip to content

Commit

Permalink
Allow breaking Vigenere without brute force
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-ion committed Jan 3, 2025
1 parent 551bd9c commit 9507b11
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion trainingportal/qna.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ let caesarEnc = (mes, key) => {
return getRes(mes, shifted);
}

let vigenereEnc = (mes, key) => {
let vigenereEnc = (m, key) => {
let keyArray = [];
let keyLen = 3;
let mes = "LOREM " + m;

if(util.isNullOrUndefined(key)){
for(let i = 0; i<keyLen; i++){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"name":"Vigenère Cipher",
"description": "crypto_vigenere.md",
"type":"quiz",
"mission":"Decrypt the cipher below. As before, the plain text is in Latin.",
"mission":"Decrypt the cipher below knowing that the first word is 'LOREM'.",
"codeBlockIds":[]
},
{
Expand Down
12 changes: 2 additions & 10 deletions trainingportal/test/qna.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,14 @@ describe("qna", () => {
let text = "PLAIN TEXT";
for(let alg in qna.DEFS){
if(alg === "crypto_analysis") continue;
let res = qna.getCode(alg,text);
let res = qna.getCode(alg,text);
if(alg === "crypto_vigenere") text = "LOREM " + text;
let check = qna.checkCode(text, res.digest);
assert(check === true, `Validation failed for correct text using ${alg}`);
}
});


test("vigenere should return plain text for 'AAA'",()=>{
let text = "PLAIN TEXT";
let expected = "BYOUA HQKH"
let key = "MNO"
let res = qna.getCode("crypto_vigenere",text,key);
assert.strictEqual(res.code, expected, "Did not result in the same cipher for key: 'MNO'");

});

test("xorOp should return plain text for '0x0'",()=>{
let text = "PLAIN TEXT";
let expected = "50 4C 41 49 4E 20 54 45 58 54";
Expand Down

0 comments on commit 9507b11

Please sign in to comment.