MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / adler32

Function adler32

app/src/IO/Checksum.cpp:169–180  ·  view source on GitHub ↗

* @brief Computes the Adler-32 checksum of the input data. */

Source from the content-addressed store, hash-verified

167 * @brief Computes the Adler-32 checksum of the input data.
168 */
169static constexpr uint32_t adler32(const char* data, const int length) noexcept
170{
171 constexpr uint32_t kModAdler = 65521;
172 uint32_t a = 1, b = 0;
173
174 for (int i = 0; i < length; ++i) {
175 a = (a + static_cast<uint8_t>(data[i])) % kModAdler;
176 b = (b + a) % kModAdler;
177 }
178
179 return (b << 16) | a;
180}
181
182/**
183 * @brief Computes a Fletcher-16 checksum.

Callers 4

calculateMethod · 0.85
resetMethod · 0.85
updateMethod · 0.85
Checksum.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected