mirror of https://github.com/ArduPilot/ardupilot
AP_Math: add method for generating hash
This commit is contained in:
parent
2b410479af
commit
fb48d8ee1b
|
@ -255,3 +255,14 @@ uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len)
|
|||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
// FNV-1a implementation
|
||||
#define FNV_1_PRIME_64 1099511628211UL
|
||||
void hash_fnv_1a(uint32_t len, const uint8_t* buf, uint64_t* hash)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i=0; i<len; i++) {
|
||||
*hash ^= (uint64_t)buf[i];
|
||||
*hash *= FNV_1_PRIME_64;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,3 +29,7 @@ uint16_t crc16_ccitt(const uint8_t *buf, uint32_t len, uint16_t crc);
|
|||
|
||||
uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len);
|
||||
|
||||
// generate 64bit FNV1a hash from buffer
|
||||
#define FNV_1_OFFSET_BASIS_64 14695981039346656037UL
|
||||
void hash_fnv_1a(uint32_t len, const uint8_t* buf, uint64_t* hash);
|
||||
|
||||
|
|
Loading…
Reference in New Issue