Botan  1.11.15
src/lib/hash/checksum/adler32/adler32.h
Go to the documentation of this file.
00001 /*
00002 * Adler32
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_ADLER32_H__
00009 #define BOTAN_ADLER32_H__
00010 
00011 #include <botan/hash.h>
00012 
00013 namespace Botan {
00014 
00015 /**
00016 * The Adler32 checksum, used in zlib
00017 */
00018 class BOTAN_DLL Adler32 : public HashFunction
00019    {
00020    public:
00021       std::string name() const { return "Adler32"; }
00022       size_t output_length() const { return 4; }
00023       HashFunction* clone() const { return new Adler32; }
00024 
00025       void clear() { S1 = 1; S2 = 0; }
00026 
00027       Adler32() { clear(); }
00028       ~Adler32() { clear(); }
00029    private:
00030       void add_data(const byte[], size_t);
00031       void final_result(byte[]);
00032       u16bit S1, S2;
00033    };
00034 
00035 }
00036 
00037 #endif