[1096] | 1 | /*
|
---|
| 2 | Copyright (C) 2005-2014 Sergey A. Tachenov
|
---|
| 3 |
|
---|
| 4 | This file is part of QuaZIP.
|
---|
| 5 |
|
---|
| 6 | QuaZIP is free software: you can redistribute it and/or modify
|
---|
| 7 | it under the terms of the GNU Lesser General Public License as published by
|
---|
| 8 | the Free Software Foundation, either version 2.1 of the License, or
|
---|
| 9 | (at your option) any later version.
|
---|
| 10 |
|
---|
| 11 | QuaZIP is distributed in the hope that it will be useful,
|
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | GNU Lesser General Public License for more details.
|
---|
| 15 |
|
---|
| 16 | You should have received a copy of the GNU Lesser General Public License
|
---|
| 17 | along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 18 |
|
---|
| 19 | See COPYING file for the full LGPL text.
|
---|
| 20 |
|
---|
| 21 | Original ZIP package is copyrighted by Gilles Vollant and contributors,
|
---|
| 22 | see quazip/(un)zip.h files for details. Basically it's the zlib license.
|
---|
| 23 | */
|
---|
| 24 |
|
---|
| 25 | #include "quacrc32.h"
|
---|
| 26 |
|
---|
| 27 | #include "zlib.h"
|
---|
| 28 |
|
---|
| 29 | QuaCrc32::QuaCrc32()
|
---|
| 30 | {
|
---|
| 31 | reset();
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | quint32 QuaCrc32::calculate(const QByteArray &data)
|
---|
| 35 | {
|
---|
| 36 | return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | void QuaCrc32::reset()
|
---|
| 40 | {
|
---|
| 41 | checksum = crc32(0L, Z_NULL, 0);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | void QuaCrc32::update(const QByteArray &buf)
|
---|
| 45 | {
|
---|
| 46 | checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | quint32 QuaCrc32::value()
|
---|
| 50 | {
|
---|
| 51 | return checksum;
|
---|
| 52 | }
|
---|