Skip to content

Commit 9730ce1

Browse files
committed
Merge branch 'fix-windows-filetime' of https://github.com/mikecat/CyberChef
2 parents 55a7981 + 3086c25 commit 9730ce1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: src/core/operations/UNIXTimestampToWindowsFiletime.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class UNIXTimestampToWindowsFiletime extends Operation {
7979
flipped += result.charAt(i);
8080
flipped += result.charAt(i + 1);
8181
}
82+
if (result.length % 2 !== 0) {
83+
flipped += "0" + result.charAt(0);
84+
}
8285
result = flipped;
8386
}
8487

Diff for: src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class WindowsFiletimeToUNIXTimestamp extends Operation {
5252
if (format === "Hex (little endian)") {
5353
// Swap endianness
5454
let result = "";
55-
for (let i = input.length - 2; i >= 0; i -= 2) {
55+
if (input.length % 2 !== 0) {
56+
result += input.charAt(input.length - 1);
57+
}
58+
for (let i = input.length - input.length % 2 - 2; i >= 0; i -= 2) {
5659
result += input.charAt(i);
5760
result += input.charAt(i + 1);
5861
}

0 commit comments

Comments
 (0)