mirror of
https://github.com/gchq/CyberChef
synced 2025-12-14 15:23:20 +00:00
Added big and little endian options for Windows timestamp conversion ops
This commit is contained in:
@@ -34,7 +34,7 @@ class UNIXTimestampToWindowsFiletime extends Operation {
|
||||
{
|
||||
"name": "Output format",
|
||||
"type": "option",
|
||||
"value": ["Decimal", "Hex"]
|
||||
"value": ["Decimal", "Hex (big endian)", "Hex (little endian)"]
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -65,11 +65,24 @@ class UNIXTimestampToWindowsFiletime extends Operation {
|
||||
|
||||
input = input.plus(new BigNumber("116444736000000000"));
|
||||
|
||||
if (format === "Hex") {
|
||||
return input.toString(16);
|
||||
let result;
|
||||
if (format.startsWith("Hex")) {
|
||||
result = input.toString(16);
|
||||
} else {
|
||||
return input.toFixed();
|
||||
result = input.toFixed();
|
||||
}
|
||||
|
||||
if (format === "Hex (little endian)") {
|
||||
// Swap endianness
|
||||
let flipped = "";
|
||||
for (let i = result.length - 2; i >= 0; i -= 2) {
|
||||
flipped += result.charAt(i);
|
||||
flipped += result.charAt(i + 1);
|
||||
}
|
||||
result = flipped;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user