My Project  + 80db3
crc32.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2014 Daniel Scharrer
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the author(s) be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  */
20 
26 #ifndef INNOEXTRACT_CRYPTO_CRC32_HPP
27 #define INNOEXTRACT_CRYPTO_CRC32_HPP
28 
29 #include <boost/cstdint.hpp>
30 
31 #include "crypto/checksum.hpp"
32 
33 namespace crypto {
34 
36 struct crc32 : public checksum_base<crc32> {
37 
38  void init() { crc = CRC32_NEGL; }
39 
40  void update(const char * data, size_t length);
41 
42  boost::uint32_t finalize() const { return crc ^ CRC32_NEGL; }
43 
44 private:
45 
46  static const boost::uint32_t CRC32_NEGL = 0xffffffffl;
47 
48  boost::uint32_t crc;
49 };
50 
51 } // namespace crypto
52 
53 #endif // INNOEXTRACT_CRYPTO_CRC32_HPP
Checksum structures and utilities.
boost::uint32_t finalize() const
Definition: crc32.hpp:42
void update(const char *data, size_t length)
Definition: crc32.cpp:94
CRC32 checksum calculation.
Definition: crc32.hpp:36
void init()
Definition: crc32.hpp:38