/*
 * $Id: checksum.c 464 2019-08-01 02:15:54Z true $
 * begin 20190612 true
 *
 * nothing special, good enough, untested, no warranty, gfy, etc
 */


#include <stdint.h>


uint8_t checksum_gen(uint8_t *dat, uint8_t len)
{
	uint8_t r = 0;

	while (len) {
		r += *dat++;
		len--;
	}

	return r;
}

bit checksum_verify(uint8_t *dat, uint8_t len, uint8_t checksum)
{
	return (checksum_gen(dat, len) == checksum) ? 1 : 0;
}


