try of unseal OMNI+
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user