try of unseal OMNI+

This commit is contained in:
Stoyan Zlatev
2024-01-31 16:31:42 +01:00
parent 22e7b947ba
commit 89a9f1649d
2 changed files with 187 additions and 105 deletions
@@ -363,18 +363,21 @@
return BitConverter.GetBytes(checksum);
}
public static byte[] CalculateCRC16(this byte[] data, ushort start, ushort length)
public static byte[] CalculateCRC16(this byte[] data, int start, int length)
{
var ui_index = start;
var test = default(byte);
var zeichen = default(byte);
var crc_result = ushort.MaxValue;
ushort crc_result = 0xFFFF;
ushort ui_index = (ushort)start;
if (data.Length >= length + start)
int maxLength = length + start;
byte test;
byte current;
if (data.Length >= maxLength)
{
while (ui_index < length + start)
while (ui_index < maxLength)
{
zeichen = data[ui_index];
current = data[ui_index];
ui_index++;
for (byte h = 0; h < 8; h++)
@@ -388,18 +391,19 @@
crc_result <<= 1;
if (((zeichen & 0x80) ^ test) != 0)
if (((current & 0x80) ^ test) != 0)
{
crc_result ^= 0x1021;
}
zeichen <<= 1;
current <<= 1;
}
maxLength = length + start;
}
}
return BitConverter.GetBytes(crc_result);
}
}
}