From 633105633bec1971b527111eeef2df8f194c8946 Mon Sep 17 00:00:00 2001 From: Wan Cheuk Lun Date: Thu, 25 Oct 2018 20:15:11 +0800 Subject: [PATCH] Create keyFinder Find and retrieve the encryption key automatically Note: This is a draft version, please help to modify, Thanks! --- Ciphers/keyFinder | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Ciphers/keyFinder diff --git a/Ciphers/keyFinder b/Ciphers/keyFinder new file mode 100644 index 000000000..5b8bd791f --- /dev/null +++ b/Ciphers/keyFinder @@ -0,0 +1,23 @@ +/****************************************************** +Find and retrieve the encryption key automatically +Note: This is a draft version, please help to modify, Thanks! +******************************************************/ +function keyFinder(){ + var result = ""; + var key = 0; + var wordbank =["is","Is","am","Am","are","Are","have","Have","has","Has","may","May","be","Be"]; + var shiftNum = 0; //count the number of key shifted + var str = document.getElementById("encryptedID").value; //get the input string + var inStr = str.toString(); //convert the input to String + var outStr = ""; // store the output value + document.getElementById("debug").innerHTML = shiftNum; + for (var i=0; i<26; i++){ + outStr = caesarCipherEncodeAndDecodeEngine(inStr,i); // use the encrytpion engine to decrypt the input string, shiftNum=i + for ( var i=0; i