FEATURE: Added ROT47 support.
Added support for ROT 47 Variation of Caesar Cipher.feature-extract-files
parent
09d515cbae
commit
20d4e5d263
|
@ -1390,6 +1390,21 @@ var OperationConfig = {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ROT47": {
|
||||||
|
description: "A slightly more complex variation of a caesar cipher, which includes ASCII characters too. (default 47)",
|
||||||
|
run: Rotate.run_rot47,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "byte_array",
|
||||||
|
output_type: "byte_array",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Amount",
|
||||||
|
type: "number",
|
||||||
|
value: Rotate.ROT47_AMOUNT
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
"Strip HTTP headers": {
|
"Strip HTTP headers": {
|
||||||
description: "Removes HTTP headers from a request or response by looking for the first instance of a double newline.",
|
description: "Removes HTTP headers from a request or response by looking for the first instance of a double newline.",
|
||||||
run: HTTP.run_strip_headers,
|
run: HTTP.run_strip_headers,
|
||||||
|
|
|
@ -126,6 +126,41 @@ var Rotate = {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
ROT47_AMOUNT: 47,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT47 operation.
|
||||||
|
*
|
||||||
|
* @param {byte_array} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {byte_array}
|
||||||
|
*/
|
||||||
|
run_rot47: function(input, args) {
|
||||||
|
var amount = args[0],
|
||||||
|
output = input,
|
||||||
|
chr;
|
||||||
|
|
||||||
|
if (amount) {
|
||||||
|
if (amount < 0) {
|
||||||
|
amount = 94 - (Math.abs(amount) % 94);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
chr = input[i];
|
||||||
|
if (chr >= 33 && chr <= 126) { // Upper case
|
||||||
|
chr = (chr - 33 + amount) % 94;
|
||||||
|
output[i] = chr + 33;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate right bitwise op.
|
* Rotate right bitwise op.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue