1 /* 2 * Adler32 3 * (C) 1999-2007 Jack Lloyd 4 * 5 * Botan is released under the Simplified BSD License (see license.txt) 6 */ 7 8 #ifndef BOTAN_ADLER32_H_ 9 #define BOTAN_ADLER32_H_ 10 11 #include <botan/hash.h> 12 13 BOTAN_FUTURE_INTERNAL_HEADER(adler32.h) 14 15 namespace Botan { 16 17 /** 18 * The Adler32 checksum, used in zlib 19 */ 20 class BOTAN_PUBLIC_API(2,0) Adler32 final : public HashFunction 21 { 22 public: name()23 std::string name() const override { return "Adler32"; } output_length()24 size_t output_length() const override { return 4; } clone()25 HashFunction* clone() const override { return new Adler32; } 26 std::unique_ptr<HashFunction> copy_state() const override; 27 clear()28 void clear() override { m_S1 = 1; m_S2 = 0; } 29 Adler32()30 Adler32() { clear(); } ~Adler32()31 ~Adler32() { clear(); } 32 private: 33 void add_data(const uint8_t[], size_t) override; 34 void final_result(uint8_t[]) override; 35 uint16_t m_S1, m_S2; 36 }; 37 38 } 39 40 #endif 41