mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Merge branch 'FromNegs' of https://github.com/qistoph/CyberChef into qistoph-FromNegs
This commit is contained in:
commit
ca47ba3c7c
3 changed files with 45 additions and 2 deletions
|
@ -29,6 +29,11 @@ class FromDecimal extends Operation {
|
||||||
"name": "Delimiter",
|
"name": "Delimiter",
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": DELIM_OPTIONS
|
"value": DELIM_OPTIONS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Convert negatives",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
this.patterns = [
|
this.patterns = [
|
||||||
|
@ -71,7 +76,11 @@ class FromDecimal extends Operation {
|
||||||
* @returns {byteArray}
|
* @returns {byteArray}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
return fromDecimal(input, args[0]);
|
let data = fromDecimal(input, args[0]);
|
||||||
|
if (args[1]) { // Convert negatives
|
||||||
|
data = data.map(v => v < 0 ? 0xFF + v + 1 : v);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ import "./tests/operations/Crypt";
|
||||||
import "./tests/operations/DateTime";
|
import "./tests/operations/DateTime";
|
||||||
import "./tests/operations/ExtractEmailAddresses";
|
import "./tests/operations/ExtractEmailAddresses";
|
||||||
import "./tests/operations/Fork";
|
import "./tests/operations/Fork";
|
||||||
import "./tests/operations/FromGeohash.mjs";
|
import "./tests/operations/FromDecimal";
|
||||||
|
import "./tests/operations/FromGeohash";
|
||||||
import "./tests/operations/Hash";
|
import "./tests/operations/Hash";
|
||||||
import "./tests/operations/HaversineDistance";
|
import "./tests/operations/HaversineDistance";
|
||||||
import "./tests/operations/Hexdump";
|
import "./tests/operations/Hexdump";
|
||||||
|
|
33
test/tests/operations/FromDecimal.mjs
Normal file
33
test/tests/operations/FromDecimal.mjs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* From Decimal tests
|
||||||
|
*
|
||||||
|
* @author qistoph
|
||||||
|
* @copyright Crown Copyright 2018
|
||||||
|
* @licence Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../TestRegister";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "From Decimal",
|
||||||
|
input: "83 97 109 112 108 101 32 84 101 120 116",
|
||||||
|
expectedOutput: "Sample Text",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "From Decimal",
|
||||||
|
args: ["Space", false]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "From Decimal with negatives",
|
||||||
|
input: "-130,-140,-152,-151,115,33,0,-1",
|
||||||
|
expectedOutput: "~this!\u0000\u00ff",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "From Decimal",
|
||||||
|
args: ["Comma", true]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Add table
Add a link
Reference in a new issue