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

Function crc32

app/src/IO/Checksum.cpp:150–164  ·  view source on GitHub ↗

* @brief Computes a 32-bit CRC (CRC-32) using polynomial 0xEDB88320. */

Source from the content-addressed store, hash-verified

148 * @brief Computes a 32-bit CRC (CRC-32) using polynomial 0xEDB88320.
149 */
150static constexpr uint32_t crc32(const char* data, const int length) noexcept
151{
152 uint32_t crc = 0xFFFFFFFF;
153
154 for (int i = 0; i < length; ++i) {
155 crc ^= static_cast<uint8_t>(data[i]);
156 for (int j = 0; j < 8; ++j)
157 if (crc & 1)
158 crc = (crc >> 1) ^ 0xEDB88320;
159 else
160 crc >>= 1;
161 }
162
163 return ~crc;
164}
165
166/**
167 * @brief Computes the Adler-32 checksum of the input data.

Callers 6

Checksum.cppFile · 0.70
unzReadCurrentFileFunction · 0.50
calculateMethod · 0.50
resetMethod · 0.50
updateMethod · 0.50
zipWriteInFileInZipFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected