mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-18 12:30:02 +02:00
include/libeosio/checksum.hpp: Adding checksum_validate function
This commit is contained in:
parent
a99a23ae9b
commit
82fc4b60cf
1 changed files with 6 additions and 0 deletions
|
|
@ -57,6 +57,12 @@ inline checksum_t checksum(const unsigned char* data, std::size_t len) {
|
||||||
return crc;
|
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.
|
* Checksum implementations.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue