mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Utils.fromHex function now defaults to automatically strip all delimiters. Fixes #295
This commit is contained in:
parent
d18a7df3bc
commit
72f7f0b70c
3 changed files with 10 additions and 5 deletions
|
@ -718,10 +718,10 @@ const Utils = {
|
||||||
* Utils.fromHex("0a:14:1e", "Colon");
|
* Utils.fromHex("0a:14:1e", "Colon");
|
||||||
*/
|
*/
|
||||||
fromHex: function(data, delim, byteLen) {
|
fromHex: function(data, delim, byteLen) {
|
||||||
delim = delim || (data.indexOf(" ") >= 0 ? "Space" : "None");
|
delim = delim || "Auto";
|
||||||
byteLen = byteLen || 2;
|
byteLen = byteLen || 2;
|
||||||
if (delim !== "None") {
|
if (delim !== "None") {
|
||||||
const delimRegex = Utils.regexRep[delim];
|
const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep[delim];
|
||||||
data = data.replace(delimRegex, "");
|
data = data.replace(delimRegex, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -624,7 +624,7 @@ const OperationConfig = {
|
||||||
{
|
{
|
||||||
name: "Delimiter",
|
name: "Delimiter",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: ByteRepr.HEX_DELIM_OPTIONS
|
value: ByteRepr.FROM_HEX_DELIM_OPTIONS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -639,7 +639,7 @@ const OperationConfig = {
|
||||||
{
|
{
|
||||||
name: "Delimiter",
|
name: "Delimiter",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: ByteRepr.HEX_DELIM_OPTIONS
|
value: ByteRepr.TO_HEX_DELIM_OPTIONS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,12 @@ const ByteRepr = {
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
HEX_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"],
|
TO_HEX_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"],
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
FROM_HEX_DELIM_OPTIONS: ["Auto", "Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"],
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue