#pragma once

#include "AbstractChecksumCalculator.h"

class Adler32Checksum : public AbstractChecksumCalculator
{
public:
    void addValue(unsigned char val) override
    {
        mSum1 = (mSum1 + val) % MOD_ADLER32;
        mSum2 = (mSum2 + mSum1) % MOD_ADLER32;
    }

    uint32_t getChecksum() const override
    {
        return (mSum2 << 16) | mSum1;
    }

    void reset() override
    {
        mSum1 = 1;
        mSum2 = 0;
    }

private:
    static constexpr unsigned MOD_ADLER32{65536};
    uint32_t mSum1{1};
    uint32_t mSum2{0};
};
