summaryrefslogtreecommitdiffstats
path: root/invensense/mlsdk/mlutils/checksum.c
blob: a97477d0cdc35806910dc403f2bd7fe72068d5c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "mltypes.h"

/** bernstein hash, from public domain source */

uint32_t inv_checksum(unsigned char *str, int len)
{
    uint32_t hash = 5381;
    int i, c;

    for (i = 0; i < len; i++) {
        c = *(str + i);
        hash = ((hash << 5) + hash) + c;    /* hash * 33 + c */
    }

    return hash;
}