mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 00:05:11 -04:00
Update MultiTapCipherDecode.mjs
Added a new argument called Representation of space which is user configurable. It allows the user to choose what to represent a space by. It has the options of Hash(#), Period (.), Percent(%) and Ampersand (&).
This commit is contained in:
parent
0dedb109fe
commit
ea7da0a824
1 changed files with 10 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
import Utils from "../Utils.mjs";
|
import Utils from "../Utils.mjs";
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import { getMultiTapMap } from "../lib/Ciphers.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +31,11 @@ class MultiTapCipherDecode extends Operation {
|
||||||
name: "Delimiter",
|
name: "Delimiter",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: ["Hyphen","Space", "Comma", "Semi-colon", "Colon", "Line feed"]
|
value: ["Hyphen","Space", "Comma", "Semi-colon", "Colon", "Line feed"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : "Representation of Space",
|
||||||
|
type: "option",
|
||||||
|
value: ["Hash","Period","Percent","Ampersand"]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -43,13 +49,14 @@ class MultiTapCipherDecode extends Operation {
|
||||||
if(input.length == 0)
|
if(input.length == 0)
|
||||||
return "";
|
return "";
|
||||||
const delim = Utils.charRep(args[0] || "Hyphen");
|
const delim = Utils.charRep(args[0] || "Hyphen");
|
||||||
var emap = {"2":"A","22":"B","222":"C","3":"D","33":"E","333":"F","4":"G","44":"H","444":"I","5":"J","55":"K","555":"L","6":"M","66":"N","666":"O","7":"P","77":"Q","777":"R","7777":"S","8":"T","88":"U","888":"V","9":"W","99":"X","999":"Y","9999":"Z"," ":" "}
|
const space_delim = Utils.charRep(args[1] || "Hash");
|
||||||
|
var dmap = getMultiTapMap(2,space_delim);
|
||||||
var enc_list = input.split(delim);
|
var enc_list = input.split(delim);
|
||||||
var plaintext = "";
|
var plaintext = "";
|
||||||
for(let i=0;i<enc_list.length;i++){
|
for(let i=0;i<enc_list.length;i++){
|
||||||
if(emap[enc_list[i]] == undefined)
|
if(dmap[enc_list[i]] == undefined)
|
||||||
throw new OperationError("Invalid Input\nThe numbers must range from 2-9 and must be separated by the delimiter chosen");
|
throw new OperationError("Invalid Input\nThe numbers must range from 2-9 and must be separated by the delimiter chosen");
|
||||||
plaintext += emap[enc_list[i]];
|
plaintext += dmap[enc_list[i]];
|
||||||
}
|
}
|
||||||
return plaintext;
|
return plaintext;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue