1
0
Fork 0
mirror of https://github.com/eosswedenorg/libantelope synced 2026-06-16 03:34:56 +02:00

include/libeosio/checksum.hpp: Adding checksum_validate function

This commit is contained in:
Henrik Hautakoski 2023-03-10 11:11:39 +01:00
parent a99a23ae9b
commit 82fc4b60cf

View file

@ -57,6 +57,12 @@ inline checksum_t checksum(const unsigned char* data, std::size_t len) {
return crc;
}
template <checksum_t (*F)(const unsigned char *, std::size_t)>
inline bool checksum_validate(const unsigned char* data, std::size_t len) {
checksum_t check = F(data, len - CHECKSUM_SIZE);
return !memcmp(check.data(), data + (len - CHECKSUM_SIZE), CHECKSUM_SIZE);
}
/**
* Checksum implementations.
*/