CMSDK  2.0.1
crc32.h
1 // //////////////////////////////////////////////////////////
2 // crc32.h
3 // Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.
4 // see http://create.stephan-brumme.com/disclaimer.html
5 //
6 
7 #pragma once
8 
9 //#include "hash.h"
10 #include <string>
11 
12 // define fixed size integer types
13 #ifdef _MSC_VER
14 // Windows
15 typedef unsigned __int8 uint8_t;
16 typedef unsigned __int32 uint32_t;
17 #else
18 // GCC
19 #include <stdint.h>
20 #endif
21 
22 
24 
41 class CRC32 //: public Hash
42 {
43 public:
45  enum { HashBytes = 4 };
46 
48  CRC32();
49 
51  std::string operator()(const void* data, size_t numBytes);
53  std::string operator()(const std::string& text);
54 
56  void add(const void* data, size_t numBytes);
57 
59  std::string getHash();
61  void getHash(unsigned char buffer[HashBytes]);
62 
64  void reset();
65 
66 private:
68  uint32_t m_hash;
69 };
std::string getHash()
return latest hash as 8 hex characters
Definition: crc32.cpp:383
void add(const void *data, size_t numBytes)
add arbitrary number of bytes
Definition: crc32.cpp:339
CRC32()
same as reset()
Definition: crc32.cpp:16
void reset()
restart
Definition: crc32.cpp:23
std::string operator()(const void *data, size_t numBytes)
compute CRC32 of a memory block
Definition: crc32.cpp:417
compute CRC32 hash, based on Intel&#39;s Slicing-by-8 algorithm
Definition: crc32.h:41