I need to compute hashes of multiple blocks of data independently. Something like this:
using( HashAlgorithm hasher = new ActualHashAlgorithm() ) {
for( int i = 0; i = numberOfBlocks; i++ ) {
byte[] block = getBlock( i );
byte[] hash = hasher.ComputeHash( block );
// use hash
}
}
Can I reuse the same HashAlgorithm object between blocks? Will HashAlgorithm reset state between calls to ComputeHash() or do I need to dispose the HashAlgorithm object and create new one for each new block of data?
Using ComputeHash is usually stateless although it depends on the actual implementation... you can check that at runtime by accessing State after the call to ComputeHash...
see
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With