You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to calculate a crc32 checksum with LSB bit-ordering and a start value of 0xFFFFFFFF.
This seems to be impossible with this library.
By using the public static uint Append(uint initial, byte[] input, int offset, int length) function, you can specify a start value (by using the uint initial argument to do so). However it is not possible to specify the bit-ordering when using the static functions.
It is possible to specify the bit-ordering by instantiating the public class Crc32Algorithm : HashAlgorithm via the constructor argument bool isBigEndian. However, using an instance it is not possible to set a start value since public abstract class HashAlgorithm : IDisposable, ICryptoTransform has no functionality for it.
The text was updated successfully, but these errors were encountered:
Main usage of instance methods is to use as specific implementation of HashAlgorithm class. Ordering is only used in HashFinal method, when byte array is needed.
If you use crc32 as 'integer' value, there is no difference in bit ordering.
To convert to byte array manually, you can use BitConverter.GetBytes or use such code:
Whoops, i thought the bool isBigEndian argument was used to indicate the bit-order of the input data (the old Endian vs. LSB/MSB confusion).
that certainly explains why i could not reproduce any checksums i generated with this lib with other tools.
I will swap the bit-order of my input data manually then.
Adding support for an initial value for the instance methods would be quite nice, since there are quite a few usecases where a start value of 0xFFFFFFFF is used.
should i close this issue or do you want to use it to keep track of the potential improvement regarding the initial value for instance methods?
Blenderpics
changed the title
LSB + Initial value can't be calculated with the current implementation
Missing functionality for setting the initial value when using instance methods
Aug 10, 2018
I need to calculate a crc32 checksum with LSB bit-ordering and a start value of 0xFFFFFFFF.
This seems to be impossible with this library.
By using the
public static uint Append(uint initial, byte[] input, int offset, int length)
function, you can specify a start value (by using theuint initial
argument to do so). However it is not possible to specify the bit-ordering when using the static functions.It is possible to specify the bit-ordering by instantiating the
public class Crc32Algorithm : HashAlgorithm
via the constructor argumentbool isBigEndian
. However, using an instance it is not possible to set a start value sincepublic abstract class HashAlgorithm : IDisposable, ICryptoTransform
has no functionality for it.The text was updated successfully, but these errors were encountered: