Merge branch 'feature_vigenere'
Conflicts: build/prod/cyberchef.htm build/prod/index.html build/prod/scripts.js src/static/stats.txtfeature-extract-files
commit
f2b22605ab
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,8 @@ var Categories = [
|
||||||
"XOR Brute Force",
|
"XOR Brute Force",
|
||||||
"Derive PBKDF2 key",
|
"Derive PBKDF2 key",
|
||||||
"Derive EVP key",
|
"Derive EVP key",
|
||||||
|
"Vigenere Encode",
|
||||||
|
"Vigenere Decode"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1325,6 +1325,36 @@ var OperationConfig = {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Vigenere Encode": {
|
||||||
|
description: "Encodes string with the Vigenere cipher.",
|
||||||
|
run: Cipher.run_vigenc,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "string",
|
||||||
|
output_type: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Keyword",
|
||||||
|
type: "string",
|
||||||
|
value: Cipher.VIG_ENC_KEY
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Vigenere Decode": {
|
||||||
|
description: "Decodes string with the Vigenere cipher.",
|
||||||
|
run: Cipher.run_vigdec,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "string",
|
||||||
|
output_type: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Keyword",
|
||||||
|
type: "string",
|
||||||
|
value: Cipher.VIG_DEC_KEY
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"Rotate right": {
|
"Rotate right": {
|
||||||
description: "Rotates each byte to the right by the number of bits specified. Currently only supports 8-bit values.",
|
description: "Rotates each byte to the right by the number of bits specified. Currently only supports 8-bit values.",
|
||||||
run: Rotate.run_rotr,
|
run: Rotate.run_rotr,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* Cipher operations.
|
* Cipher operations.
|
||||||
*
|
*
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
* @author n1474335 [n1474335@gmail.com] & Matt C [matt@artemisbot.pw]
|
||||||
* @copyright Crown Copyright 2016
|
* @copyright Crown Copyright 2016
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -385,6 +385,101 @@ var Cipher = {
|
||||||
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
VIG_ENC_KEY: "cipher",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vigenere cipher encode.
|
||||||
|
*
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run_vigenc: function (input, args) {
|
||||||
|
var alphabet = "abcdefghijklmnopqrstuvwxyz",
|
||||||
|
keyword = args[0].toLowerCase(),
|
||||||
|
output = "",
|
||||||
|
fail = 0,
|
||||||
|
keyIndex,
|
||||||
|
msgIndex,
|
||||||
|
chr;
|
||||||
|
if (keyword) {
|
||||||
|
if (/^[a-zA-Z]+$/.test(keyword)) {
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if (alphabet.indexOf(input[i]) >= 0) {
|
||||||
|
chr = keyword[(i - fail) % keyword.length]; //Gets the corresponding character of keyword for current letter, accounting for chars not in alphabet
|
||||||
|
keyIndex = alphabet.indexOf(chr); //Gets location in vigenere square of keyword char
|
||||||
|
msgIndex = alphabet.indexOf(input[i]); //Gets location in vigenere square of message char
|
||||||
|
output += alphabet[(keyIndex + msgIndex) % 26]; //Gets encoded letter by finding sum of indexes modulo 26 and finding the letter corresponding to that
|
||||||
|
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
|
||||||
|
chr = keyword[(i - fail) % keyword.length].toLowerCase();
|
||||||
|
keyIndex = alphabet.indexOf(chr);
|
||||||
|
msgIndex = alphabet.indexOf(input[i].toLowerCase());
|
||||||
|
output += alphabet[(keyIndex + msgIndex) % 26].toUpperCase();
|
||||||
|
} else {
|
||||||
|
output += input[i];
|
||||||
|
fail++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw "Keyword can only consist of letters.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw "A keyword is required.";
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
VIG_DEC_KEY: "cipher",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vigenere cipher decode.
|
||||||
|
*
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run_vigdec: function (input, args) {
|
||||||
|
var alphabet = "abcdefghijklmnopqrstuvwxyz",
|
||||||
|
keyword = args[0].toLowerCase(),
|
||||||
|
output = "",
|
||||||
|
fail = 0,
|
||||||
|
keyIndex,
|
||||||
|
msgIndex,
|
||||||
|
chr;
|
||||||
|
if (keyword) {
|
||||||
|
if (/^[a-zA-Z]+$/.test(keyword)) {
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if (alphabet.indexOf(input[i]) >= 0) {
|
||||||
|
chr = keyword[(i - fail) % keyword.length];
|
||||||
|
keyIndex = alphabet.indexOf(chr);
|
||||||
|
msgIndex = alphabet.indexOf(input[i]);
|
||||||
|
output += alphabet[(msgIndex - keyIndex + alphabet.length ) % 26]; //subtract indexes from each other, add 26 just in case the value is negative, modulo to remove if neccessary
|
||||||
|
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
|
||||||
|
chr = keyword[(i - fail) % keyword.length].toLowerCase();
|
||||||
|
keyIndex = alphabet.indexOf(chr);
|
||||||
|
msgIndex = alphabet.indexOf(input[i].toLowerCase());
|
||||||
|
output += alphabet[(msgIndex + alphabet.length - keyIndex) % 26].toUpperCase();
|
||||||
|
} else {
|
||||||
|
output += input[i];
|
||||||
|
fail++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw "Keyword can only consist of letters.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw "A keyword is required.";
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
203 source files
|
203 source files
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
104269 lines
|
104269 lines
|
||||||
size
|
size
|
||||||
|
|
||||||
136 JavaScript source files
|
136 JavaScript source files
|
||||||
95179 lines
|
95179 lines
|
||||||
|
=======
|
||||||
|
104345 lines
|
||||||
|
size
|
||||||
|
|
||||||
|
136 JavaScript source files
|
||||||
|
95255 lines
|
||||||
|
>>>>>>> feature_vigenere
|
||||||
3.5M size
|
3.5M size
|
||||||
=======
|
=======
|
||||||
104221 lines
|
104221 lines
|
||||||
|
@ -21,15 +29,24 @@
|
||||||
|
|
||||||
58 first party JavaScript source files
|
58 first party JavaScript source files
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
18802 lines
|
18802 lines
|
||||||
736K size
|
736K size
|
||||||
=======
|
=======
|
||||||
|
18878 lines
|
||||||
|
740K size
|
||||||
|
>>>>>>> feature_vigenere
|
||||||
|
=======
|
||||||
18754 lines
|
18754 lines
|
||||||
724K size
|
724K size
|
||||||
>>>>>>> master
|
>>>>>>> master
|
||||||
|
|
||||||
3.1M uncompressed JavaScript size
|
3.2M uncompressed JavaScript size
|
||||||
1.7M compressed JavaScript size
|
1.7M compressed JavaScript size
|
||||||
|
|
||||||
15 categories
|
15 categories
|
||||||
|
<<<<<<< HEAD
|
||||||
153 operations
|
153 operations
|
||||||
|
=======
|
||||||
|
154 operations
|
||||||
|
>>>>>>> feature_vigenere
|
||||||
|
|
Loading…
Reference in New Issue