add e_auth_hash_djb2 inline

all eina hash functions are now useless for any case where the hashed value needs to be stored, so it's necessary for e to provide its own hash function to use for password storage
This commit is contained in:
Mike Blumenkrantz 2014-09-05 15:02:10 -04:00
parent 6318fd042b
commit 721dfe82c2
1 changed files with 13 additions and 0 deletions

View File

@ -4,4 +4,17 @@
EAPI int e_auth_begin(char *passwd);
EAPI char *e_auth_hostname_get(void);
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