/*
 * checksum.c
 * begin 20190612 true
 *
 * nothing special, good enough, untested, no warranty, gfy, etc
 */


#include <stdint.h>


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

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

	return r;
}

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