Added 'Decimal' option for toggleStrings. Closes #337.

This commit is contained in:
n1474335 2018-08-19 22:50:49 +01:00
parent c1b2fc9400
commit affe057cab
10 changed files with 51 additions and 21 deletions

View file

@ -29,7 +29,7 @@ class ADD extends Operation {
"name": "Key",
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"]
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
}
];
}

View file

@ -29,7 +29,7 @@ class AND extends Operation {
"name": "Key",
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"]
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
}
];
}

View file

@ -5,8 +5,8 @@
*/
import Operation from "../Operation";
import Utils from "../Utils";
import {DELIM_OPTIONS} from "../lib/Delim";
import {fromDecimal} from "../lib/Decimal";
/**
* From Decimal operation
@ -71,16 +71,7 @@ class FromDecimal extends Operation {
* @returns {byteArray}
*/
run(input, args) {
const delim = Utils.charRep(args[0]),
output = [];
let byteStr = input.split(delim);
if (byteStr[byteStr.length-1] === "")
byteStr = byteStr.slice(0, byteStr.length-1);
for (let i = 0; i < byteStr.length; i++) {
output[i] = parseInt(byteStr[i], 10);
}
return output;
return fromDecimal(input, args[0]);
}
}

View file

@ -86,7 +86,7 @@ class FromHex extends Operation {
* @returns {byteArray}
*/
run(input, args) {
const delim = args[0] || "Space";
const delim = args[0] || "Auto";
return fromHex(input, delim, 2);
}

View file

@ -29,7 +29,7 @@ class OR extends Operation {
"name": "Key",
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"]
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
}
];
}

View file

@ -29,7 +29,7 @@ class SUB extends Operation {
"name": "Key",
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"]
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
}
];
}

View file

@ -29,7 +29,7 @@ class XOR extends Operation {
"name": "Key",
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "Base64", "UTF8", "Latin1"]
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
},
{
"name": "Scheme",