2023-08-26 10:33:12 +00:00
|
|
|
/**
|
|
|
|
* @file CRC32.h
|
|
|
|
* @author apio (cloudapio.eu)
|
|
|
|
* @brief CRC32 checksum calculation.
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2023, the Luna authors.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-06-17 10:03:37 +00:00
|
|
|
#pragma once
|
|
|
|
#include <luna/Types.h>
|
|
|
|
|
2023-08-26 10:33:12 +00:00
|
|
|
/**
|
|
|
|
* @brief A class to calculate a CRC32 checksum.
|
|
|
|
*/
|
2023-08-15 17:27:09 +00:00
|
|
|
class CRC32
|
2023-06-17 10:03:37 +00:00
|
|
|
{
|
2023-08-15 17:27:09 +00:00
|
|
|
public:
|
2023-08-26 10:33:12 +00:00
|
|
|
/**
|
|
|
|
* @brief Add data to the checksum.
|
|
|
|
*
|
|
|
|
* @param data The data to add.
|
|
|
|
* @param size The amount of bytes to add.
|
|
|
|
*/
|
2023-08-15 17:27:09 +00:00
|
|
|
void append(const u8* data, usize size);
|
|
|
|
|
2023-08-26 10:33:12 +00:00
|
|
|
/**
|
|
|
|
* @brief Calculate the final checksum.
|
|
|
|
*
|
|
|
|
* @return u32 The calculated checksum.
|
|
|
|
*/
|
2023-08-15 17:27:09 +00:00
|
|
|
u32 digest();
|
|
|
|
|
|
|
|
private:
|
|
|
|
u32 m_checksum = 0xffffffffu;
|
|
|
|
};
|