Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
998 B

  1. #ifndef CRYPTOPP_CRC32_H
  2. #define CRYPTOPP_CRC32_H
  3. #include "cryptlib.h"
  4. NAMESPACE_BEGIN(CryptoPP)
  5. const word32 CRC32_NEGL = 0xffffffffL;
  6. #ifdef IS_LITTLE_ENDIAN
  7. #define CRC32_INDEX(c) (c & 0xff)
  8. #define CRC32_SHIFTED(c) (c >> 8)
  9. #else
  10. #define CRC32_INDEX(c) (c >> 24)
  11. #define CRC32_SHIFTED(c) (c << 8)
  12. #endif
  13. //! CRC Checksum Calculation
  14. class CRC32 : public HashTransformation
  15. {
  16. public:
  17. CRYPTOPP_CONSTANT(DIGESTSIZE = 4)
  18. CRC32();
  19. void Update(const byte *input, size_t length);
  20. void TruncatedFinal(byte *hash, size_t size);
  21. unsigned int DigestSize() const {return DIGESTSIZE;}
  22. static const char * StaticAlgorithmName() {return "CRC32";}
  23. std::string AlgorithmName() const {return StaticAlgorithmName();}
  24. void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
  25. byte GetCrcByte(size_t i) const {return ((byte *)&(m_crc))[i];}
  26. private:
  27. void Reset() {m_crc = CRC32_NEGL;}
  28. static const word32 m_tab[256];
  29. word32 m_crc;
  30. };
  31. NAMESPACE_END
  32. #endif