|
scclib
Stable Cloud Computing C++ Library
|
Adler-32 checksum allowing rolling calculation. More...
#include <adler32.h>
Public Member Functions | |
| Adler32 () | |
| Construct with initialized value. | |
| Adler32 (const void *loc, int len) | |
| Construct with initial value. More... | |
| operator uint32_t () const | |
| uint32_t | val () const |
| int | size () |
| Size of the current window. | |
| uint32_t | reset () |
| Reset the checksum. | |
| uint32_t | reset (const void *loc, int len) |
| Reset the checksum, and update with initial value. More... | |
| uint32_t | update (const void *, int) |
| Update the checksum with buffer contents. More... | |
| uint32_t | combine (const Adler32 &) |
| uint32_t | rotate (unsigned char, unsigned char) |
| Update the checksum with next byte. More... | |
| uint32_t | rotate (char xrem, char xadd) |
Adler-32 checksum allowing rolling calculation.
Rolling calculation allows very fast calculations within a sliding window, removing the overhead of recalculating for the entire window size.
Test example from scclib/encode/unittest/adler32.cc
|
inline |
|
inline |
| uint32_t Adler32::rotate | ( | unsigned char | xrem, |
| unsigned char | xadd | ||
| ) |
Update the checksum with next byte.
Usable for a "rolling window" checksum.
For example for bytes 01234 with checksum ch1, calling rotate('0', '5') will produce a checksum ad2 on bytes 12345.
| xrem | Byte to rotate out (first in old window) |
| xadd | Byte to rotate in (last in new window) |
see https://openresearch-repository.anu.edu.au/bitstream/1885/40765/3/TR-CS-96-05.pdf
Definition at line 36 of file adler32.cc.
| uint32_t Adler32::update | ( | const void * | loc, |
| int | len | ||
| ) |
Update the checksum with buffer contents.
| loc | Buffer location. |
| len | Buffer size. Window length is increased by len. |
Definition at line 7 of file adler32.cc.