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 |
|
---|
30 | QuaAdler32::QuaAdler32()
|
---|
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 |
|
---|
40 | void QuaAdler32::reset()
|
---|
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 |
|
---|
50 | quint32 QuaAdler32::value()
|
---|
51 | {
|
---|
52 | return checksum;
|
---|
53 | }
|
---|