Crc24.cs 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Bcpg
  5. {
  6. public class Crc24
  7. {
  8. private const int Crc24Init = 0x0b704ce;
  9. private const int Crc24Poly = 0x1864cfb;
  10. private int crc = Crc24Init;
  11. public Crc24()
  12. {
  13. }
  14. public void Update(
  15. int b)
  16. {
  17. crc ^= b << 16;
  18. for (int i = 0; i < 8; i++)
  19. {
  20. crc <<= 1;
  21. if ((crc & 0x1000000) != 0)
  22. {
  23. crc ^= Crc24Poly;
  24. }
  25. }
  26. }
  27. public int GetValue()
  28. {
  29. return crc;
  30. }
  31. public int Value
  32. {
  33. get { return crc; }
  34. }
  35. public void Reset()
  36. {
  37. crc = Crc24Init;
  38. }
  39. }
  40. }
  41. #pragma warning restore
  42. #endif