adler32.h 802 B

123456789101112131415161718192021222324252627282930313233
  1. // adler32.h - originally written and placed in the public domain by Wei Dai
  2. /// \file adler32.h
  3. /// \brief Class file for ADLER-32 checksum calculations
  4. #ifndef CRYPTOPP_ADLER32_H
  5. #define CRYPTOPP_ADLER32_H
  6. #include "cryptlib.h"
  7. NAMESPACE_BEGIN(CryptoPP)
  8. /// ADLER-32 checksum calculations
  9. class Adler32 : public HashTransformation
  10. {
  11. public:
  12. CRYPTOPP_CONSTANT(DIGESTSIZE = 4);
  13. Adler32() {Reset();}
  14. void Update(const byte *input, size_t length);
  15. void TruncatedFinal(byte *hash, size_t size);
  16. unsigned int DigestSize() const {return DIGESTSIZE;}
  17. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Adler32";}
  18. std::string AlgorithmName() const {return StaticAlgorithmName();}
  19. private:
  20. void Reset() {m_s1 = 1; m_s2 = 0;}
  21. word16 m_s1, m_s2;
  22. };
  23. NAMESPACE_END
  24. #endif