5752
|
1 |
#include "quacrc32.h"
|
|
2 |
|
|
3 |
#include "zlib.h"
|
|
4 |
|
|
5 |
QuaCrc32::QuaCrc32()
|
|
6 |
{
|
|
7 |
reset();
|
|
8 |
}
|
|
9 |
|
|
10 |
quint32 QuaCrc32::calculate(const QByteArray &data)
|
|
11 |
{
|
|
12 |
return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
|
|
13 |
}
|
|
14 |
|
|
15 |
void QuaCrc32::reset()
|
|
16 |
{
|
|
17 |
checksum = crc32(0L, Z_NULL, 0);
|
|
18 |
}
|
|
19 |
|
|
20 |
void QuaCrc32::update(const QByteArray &buf)
|
|
21 |
{
|
|
22 |
checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
|
|
23 |
}
|
|
24 |
|
|
25 |
quint32 QuaCrc32::value()
|
|
26 |
{
|
|
27 |
return checksum;
|
|
28 |
}
|