Annotation of elwix/tools/oldlzma/SRC/Common/CRC.h, revision 1.1
1.1 ! misho 1: // Common/CRC.h
! 2:
! 3: #ifndef __COMMON_CRC_H
! 4: #define __COMMON_CRC_H
! 5:
! 6: #include "Types.h"
! 7:
! 8: class CCRC
! 9: {
! 10: UInt32 _value;
! 11: public:
! 12: static UInt32 Table[256];
! 13: static void InitTable();
! 14:
! 15: CCRC(): _value(0xFFFFFFFF){};
! 16: void Init() { _value = 0xFFFFFFFF; }
! 17: void UpdateByte(Byte v);
! 18: void UpdateUInt16(UInt16 v);
! 19: void UpdateUInt32(UInt32 v);
! 20: void UpdateUInt64(UInt64 v);
! 21: void Update(const void *data, UInt32 size);
! 22: UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
! 23: static UInt32 CalculateDigest(const void *data, UInt32 size)
! 24: {
! 25: CCRC crc;
! 26: crc.Update(data, size);
! 27: return crc.GetDigest();
! 28: }
! 29: static bool VerifyDigest(UInt32 digest, const void *data, UInt32 size)
! 30: {
! 31: return (CalculateDigest(data, size) == digest);
! 32: }
! 33: };
! 34:
! 35: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>