1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 17:27:35 +00:00
serenity/Userland/Libraries/LibCrypto/Checksum/CRC32.h
Lenny Maiorani 6bd880c404 LibCrypto: Simplify and move CRC32 table to cpp file
CRC32 table is generated at compile-time and put into a static
variable in the header file. This can be moved to be a function
instead of a class, be moved to the `.cpp` file` and generated as an
array instead of a class which only implements `operator[]`.
2022-02-26 17:49:47 +00:00

36 lines
625 B
C++

/*
* Copyright (c) 2020-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Span.h>
#include <AK/Types.h>
#include <LibCrypto/Checksum/ChecksumFunction.h>
namespace Crypto::Checksum {
class CRC32 : public ChecksumFunction<u32> {
public:
CRC32() { }
CRC32(ReadonlyBytes data)
{
update(data);
}
CRC32(u32 initial_state, ReadonlyBytes data)
: m_state(initial_state)
{
update(data);
}
virtual void update(ReadonlyBytes data) override;
virtual u32 digest() override;
private:
u32 m_state { ~0u };
};
}