Fixed Percent delimiter for hex encoding (#2137)
Co-authored-by: GCHQ Developer 85297 <95289555+C85297@users.noreply.github.com>
This commit is contained in:
parent
fe69ec5881
commit
324a23585e
@ -33,7 +33,7 @@ export function toHex(data, delim=" ", padding=2, extraDelim="", lineSize=0) {
|
||||
if (data instanceof ArrayBuffer) data = new Uint8Array(data);
|
||||
|
||||
let output = "";
|
||||
const prepend = (delim === "0x" || delim === "\\x");
|
||||
const prepend = (delim === "0x" || delim === "\\x" || delim === "%");
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const hex = data[i].toString(16).padStart(padding, "0");
|
||||
|
||||
@ -43,6 +43,20 @@ TestRegister.addTests([
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "ASCII to Hex with percent deliminator",
|
||||
input: "aberystwyth",
|
||||
expectedOutput: "%61%62%65%72%79%73%74%77%79%74%68",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": [
|
||||
"Percent",
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "ASCII to 0x Hex with comma and line breaks",
|
||||
input: "aberystwyth",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user