Crc24.cs 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.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 Value
  28. {
  29. get { return crc; }
  30. }
  31. public void Reset()
  32. {
  33. crc = Crc24Init;
  34. }
  35. }
  36. }
  37. #pragma warning restore
  38. #endif