MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / adler32

Function adler32

libraries/Adler/Adler.cpp:19–35  ·  view source on GitHub ↗

///////////////////////////////////////////////////////// STATIC FUNCTION

Source from the content-addressed store, hash-verified

17// STATIC FUNCTION
18//
19uint32_t adler32(uint8_t * array, uint16_t length, uint32_t s1, uint32_t s2)
20{
21 uint32_t _s1 = s1;
22 uint32_t _s2 = s2;
23 for (uint16_t i = 0; i < length;)
24 {
25 // if _s2 is halfway it is time to do modulo
26 while ((i < length) && (_s2 < 2147483648ULL)) // MAGIC NR.
27 {
28 _s1 += array[i++];
29 _s2 += _s1;
30 }
31 _s1 %= ADLER32_MOD_PRIME;
32 _s2 %= ADLER32_MOD_PRIME;
33 }
34 return (_s2 << 16) | _s1;
35}
36
37
38uint16_t adler16(uint8_t * array, uint16_t length, uint16_t s1, uint16_t s2)

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68