IChecksum.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. namespace ICSharpCode.SharpZipLib.Checksum
  3. {
  4. /// <summary>
  5. /// Interface to compute a data checksum used by checked input/output streams.
  6. /// A data checksum can be updated by one byte or with a byte array. After each
  7. /// update the value of the current checksum can be returned by calling
  8. /// <code>getValue</code>. The complete checksum object can also be reset
  9. /// so it can be used again with new data.
  10. /// </summary>
  11. public interface IChecksum
  12. {
  13. /// <summary>
  14. /// Resets the data checksum as if no update was ever called.
  15. /// </summary>
  16. void Reset();
  17. /// <summary>
  18. /// Returns the data checksum computed so far.
  19. /// </summary>
  20. long Value
  21. {
  22. get;
  23. }
  24. /// <summary>
  25. /// Adds one byte to the data checksum.
  26. /// </summary>
  27. /// <param name = "bval">
  28. /// the data value to add. The high byte of the int is ignored.
  29. /// </param>
  30. void Update(int bval);
  31. /// <summary>
  32. /// Updates the data checksum with the bytes taken from the array.
  33. /// </summary>
  34. /// <param name="buffer">
  35. /// buffer an array of bytes
  36. /// </param>
  37. void Update(byte[] buffer);
  38. /// <summary>
  39. /// Adds the byte array to the data checksum.
  40. /// </summary>
  41. /// <param name = "segment">
  42. /// The chunk of data to add
  43. /// </param>
  44. void Update(ArraySegment<byte> segment);
  45. }
  46. }