forked from enlightenment/enlightenment
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:
parent
6318fd042b
commit
721dfe82c2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue