NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 namespace hash_lib
23 {
24 
26 
43 class CRC32 //: public Hash
44 {
45 public:
47  enum { HashBytes = 4 };
48 
50  CRC32();
51 
53  std::string operator()(const void* data, size_t numBytes);
55  std::string operator()(const std::string& text);
56 
58  void add(const void* data, size_t numBytes);
59 
61  std::string getHash();
63  void getHash(unsigned char buffer[CRC32::HashBytes]);
64 
66  void reset();
67 
68 private:
70  uint32_t m_hash;
71 };
72 
73 }
std::string getHash()
return latest hash as 8 hex characters
Definition: crc32.cpp:385
void reset()
restart
Definition: crc32.cpp:25
std::string operator()(const void *data, size_t numBytes)
compute CRC32 of a memory block
Definition: crc32.cpp:419
void add(const void *data, size_t numBytes)
add arbitrary number of bytes
Definition: crc32.cpp:341
compute CRC32 hash, based on Intel's Slicing-by-8 algorithm
Definition: crc32.h:43
CRC32()
same as reset()
Definition: crc32.cpp:18