monotone

monotone Mtn Source Tree

Root/cryptopp/crc.h

1#ifndef CRYPTOPP_CRC32_H
2#define CRYPTOPP_CRC32_H
3
4#include "cryptlib.h"
5
6NAMESPACE_BEGIN(CryptoPP)
7
8const word32 CRC32_NEGL = 0xffffffffL;
9
10#ifdef IS_LITTLE_ENDIAN
11#define CRC32_INDEX(c) (c & 0xff)
12#define CRC32_SHIFTED(c) (c >> 8)
13#else
14#define CRC32_INDEX(c) (c >> 24)
15#define CRC32_SHIFTED(c) (c << 8)
16#endif
17
18//! CRC Checksum Calculation
19class CRC32 : public HashTransformation
20{
21public:
22enum {DIGESTSIZE = 4};
23CRC32();
24void Update(const byte *input, unsigned int length);
25void TruncatedFinal(byte *hash, unsigned int size);
26unsigned int DigestSize() const {return DIGESTSIZE;}
27
28void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
29byte GetCrcByte(unsigned int i) const {return ((byte *)&(m_crc))[i];}
30
31private:
32void Reset() {m_crc = CRC32_NEGL;}
33
34static const word32 m_tab[256];
35word32 m_crc;
36};
37
38NAMESPACE_END
39
40#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status