CRC-32

uint32_t cardano_checksum_crc32(const byte_t *data, size_t size)

Computes the CRC32 checksum for the given data.

This function calculates a 32-bit cyclic redundancy check (CRC32) checksum, used to detect accidental changes to raw data. CRC32 checksums are a common method for ensuring the integrity of data by producing a short, fixed-size checksum based on the input data.

Usage Example:

const char* sample_data = "Hello, world!";
size_t data_size = strlen(sample_data);

uint32_t checksum = cardano_checksum_crc32(sample_data, data_size);

printf("CRC32 Checksum: %u\n", checksum);

Note

This function does not modify the input data. If the data pointer is NULL or size is zero, the function should return 0 as the checksum, which must be handled by the caller.

Parameters:
const byte_t *data

[in] A pointer to the data block for which the CRC32 checksum is to be computed.

size_t size

[in] The size of the data block in bytes.

Returns:

Returns a 32-bit unsigned integer representing the CRC32 checksum of the provided data.