Fixed Percent delimiter for hex encoding (#2137)

Co-authored-by: GCHQ Developer 85297 <95289555+C85297@users.noreply.github.com>
This commit is contained in:
Benjamin Eriksson 2026-02-11 10:20:08 +01:00 committed by GitHub
parent fe69ec5881
commit 324a23585e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -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");

View File

@ -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",