siphash24: add helper for calculating the hash value for a string

Let's shorten some code.
This commit is contained in:
Lennart Poettering
2018-10-16 16:27:15 +02:00
parent 43d3c94e64
commit a53f90ca24
2 changed files with 7 additions and 8 deletions
+5
View File
@@ -3,6 +3,7 @@
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
struct siphash {
@@ -21,3 +22,7 @@ void siphash24_compress(const void *in, size_t inlen, struct siphash *state);
uint64_t siphash24_finalize(struct siphash *state);
uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[16]);
static inline uint64_t siphash24_string(const char *s, const uint8_t k[16]) {
return siphash24(s, strlen(s) + 1, k);
}