22 # define _RABINKARP_H_ 31 # define RABINKARP_SEED 1 38 # define RABINKARP_MULT 0x08104225U 44 # define RABINKARP_INVM 0x98f009adU 50 # define RABINKARP_ADJ 0x08104224U 53 typedef struct _rabinkarp {
59 static inline void rabinkarp_init(rabinkarp_t *sum)
62 sum->hash = RABINKARP_SEED;
66 void rabinkarp_update(rabinkarp_t *sum,
const unsigned char *buf,
size_t len);
68 static inline void rabinkarp_rotate(rabinkarp_t *sum,
unsigned char out,
72 sum->hash * RABINKARP_MULT + in - sum->mult * (out + RABINKARP_ADJ);
75 static inline void rabinkarp_rollin(rabinkarp_t *sum,
unsigned char in)
77 sum->hash = sum->hash * RABINKARP_MULT + in;
79 sum->mult *= RABINKARP_MULT;
82 static inline void rabinkarp_rollout(rabinkarp_t *sum,
unsigned char out)
85 sum->mult *= RABINKARP_INVM;
86 sum->hash -= sum->mult * (out + RABINKARP_ADJ);
89 static inline uint32_t rabinkarp_digest(rabinkarp_t *sum)