0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-05-18 19:31:17 +03:00

28 lines
1005 B
C#
Raw Permalink Normal View History

2024-11-15 14:30:06 +03:00
using System.Buffers.Binary;
2024-11-17 15:54:59 +03:00
var fileBytes = File.ReadAllBytes("C:\\Program Files (x86)\\Nikita\\Iron Strategy\\gamefont.rlb");
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
var fileCount = BinaryPrimitives.ReadInt16LittleEndian(fileBytes.AsSpan().Slice(4, 2));
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
var decodedHeader = new byte[fileCount * 32];
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
byte key1 = fileBytes[20];
byte key2 = fileBytes[21];
var decodeIndex = 0;
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
Console.WriteLine($"Keys: {key1} {key2}");
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
Console.WriteLine("Iteration " + decodeIndex.ToString("00") + "| " + string.Join(" ", decodedHeader.Take(20).Select(x => x.ToString("X2"))));
2024-11-15 14:30:06 +03:00
2024-11-17 15:54:59 +03:00
do
2024-11-15 14:30:06 +03:00
{
2024-11-17 15:54:59 +03:00
key1 = (byte) (key2 ^ (key1 << 1));
key2 = (byte) (key1 ^ (key2 >> 1));
decodedHeader[decodeIndex] = (byte) (key1 ^ fileBytes[decodeIndex + 32]);
Console.WriteLine($"Keys: {key1} {key2}");
Console.WriteLine("Iteration " + decodeIndex.ToString("00") + "| " + string.Join(" ", decodedHeader.Take(20).Select(x => x.ToString("X2"))));
decodeIndex++;
} while (decodeIndex < fileCount * 32);
File.WriteAllBytes("encoding_table.bin", decodedHeader);