aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_auth.h
blob: 2ca2837634d8abbae954ce7aa54c9056478016ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef E_AUTH_H
#define E_AUTH_H

E_API int e_auth_begin(char *passwd);

static inline int
e_auth_hash_djb2(const char *key, int len)
{
   unsigned int hash_num = 5381;
   const unsigned char *ptr;

   if (!key) return 0;
   for (ptr = (unsigned char *)key; len; ptr++, len--)
     hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */

   return (int)hash_num;
}

#endif