DigestSink.cs 859 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.IO
  6. {
  7. public class DigestSink
  8. : BaseOutputStream
  9. {
  10. private readonly IDigest mDigest;
  11. public DigestSink(IDigest digest)
  12. {
  13. this.mDigest = digest;
  14. }
  15. public virtual IDigest Digest
  16. {
  17. get { return mDigest; }
  18. }
  19. public override void WriteByte(byte b)
  20. {
  21. mDigest.Update(b);
  22. }
  23. public override void Write(byte[] buf, int off, int len)
  24. {
  25. if (len > 0)
  26. {
  27. mDigest.BlockUpdate(buf, off, len);
  28. }
  29. }
  30. }
  31. }
  32. #pragma warning restore
  33. #endif