public class IncrementalHasher
{
private readonly SHA1 _sha1 = SHA1.Create();
public void AddBlock(byte[] buffer, int bytesRead)
{
int writtenBytes = _sha1.TransformBlock(buffer, 0, bytesRead, null, 0);
Debugger.SendInfo(writtenBytes + " hashed");
}
public string FinalizeHash()
{
byte[] hashBytes = _sha1.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return Convert.ToHexStringLower(hashBytes);
}
}
public class IncrementalHasher
{
private readonly SHA1 _sha1 = SHA1.Create();
public void AddBlock(byte[] buffer, int bytesRead)
{
int writtenBytes = _sha1.TransformBlock(buffer, 0, bytesRead, null, 0);
Debugger.SendInfo(writtenBytes + " hashed");
}
public string FinalizeHash()
{
byte[] hashBytes = _sha1.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return Convert.ToHexStringLower(hashBytes);
}
}