Skip to content

Commit 3e5eba6

Browse files
authored
Extend CRC to Coerce Array to meet HashValue standards
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent 5ce4c1e commit 3e5eba6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

HashifyNet/Algorithms/CRC/CRC_Implementation.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,15 @@ private static byte[] ToBytes(ulong value, int bitLength)
286286
value >>= 8;
287287
}
288288

289+
if (valueBytes.Length != (bitLength + 7) / 8)
290+
{
291+
byte[] result = ArrayHelpers.CoerceToArray(valueBytes, bitLength);
292+
return result;
293+
}
294+
289295
return valueBytes;
290296
}
291-
297+
292298
private static ulong ReflectBits(ulong value, int bitLength)
293299
{
294300
ulong reflectedValue = 0UL;
@@ -307,3 +313,4 @@ private static ulong ReflectBits(ulong value, int bitLength)
307313
}
308314
}
309315
}
316+

0 commit comments

Comments
 (0)