ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
quaadler32.cpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2010 Adam Walczak
3 Copyright (C) 2005-2014 Sergey A. Tachenov
4 
5 This file is part of QuaZIP.
6 
7 QuaZIP is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 2.1 of the License, or
10 (at your option) any later version.
11 
12 QuaZIP is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
19 
20 See COPYING file for the full LGPL text.
21 
22 Original ZIP package is copyrighted by Gilles Vollant and contributors,
23 see quazip/(un)zip.h files for details. Basically it's the zlib license.
24 */
25 
26 #include "quaadler32.h"
27 
28 #include "zlib.h"
29 
31 {
32  reset();
33 }
34 
35 quint32 QuaAdler32::calculate(const QByteArray &data)
36 {
37  return adler32( adler32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
38 }
39 
41 {
42  checksum = adler32(0L, Z_NULL, 0);
43 }
44 
45 void QuaAdler32::update(const QByteArray &buf)
46 {
47  checksum = adler32( checksum, (const Bytef*)buf.data(), buf.size() );
48 }
49 
51 {
52  return checksum;
53 }
void update(const QByteArray &buf)
Updates the calculated checksum for the stream.
Definition: quaadler32.cpp:45
quint32 checksum
Definition: quaadler32.h:51
quint32 calculate(const QByteArray &data)
Calculates the checksum for data.
Definition: quaadler32.cpp:35
void reset()
Resets the calculation on a checksun for a stream.
Definition: quaadler32.cpp:40
quint32 value()
Value of the checksum calculated for the stream passed throw update().
Definition: quaadler32.cpp:50