blob: cbef4b66111097b35eb74b4c8d0abee3945a2ffe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef __COMMON_CRC_H
#define __COMMON_CRC_H
#include "Portable.h"
class CCRC
{
UINT32 m_Value;
public:
static UINT32 m_Table[256];
CCRC(): m_Value(0xFFFFFFFF){};
void Init() { m_Value = 0xFFFFFFFF; }
void Update(const void *aData, UINT32 aSize);
UINT32 GetDigest() const { return m_Value ^ 0xFFFFFFFF; }
static UINT32 CalculateDigest(const void *aData, UINT32 aSize)
{
CCRC aCRC;
aCRC.Update(aData, aSize);
return aCRC.GetDigest();
}
static bool VerifyDigest(UINT32 aDigest, const void *aData, UINT32 aSize)
{
return (CalculateDigest(aData, aSize) == aDigest);
}
};
#endif
|