mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-31 20:29:36 +08:00
changed djb2 to xor version
This commit is contained in:
parent
9542e37577
commit
7bd2fa7ab8
@ -57,7 +57,7 @@ unsigned int crc32h(unsigned char *message,int len) {
|
|||||||
return ;
|
return ;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void simple_hash(unsigned char *str,int len,unsigned char* res) //djb2+ sdbm
|
void simple_hash(unsigned char *str,int len,unsigned char res[8]) //djb2+ sdbm
|
||||||
{
|
{
|
||||||
u32_t hash = 5381;
|
u32_t hash = 5381;
|
||||||
u32_t hash2 = 0;
|
u32_t hash2 = 0;
|
||||||
@ -65,7 +65,8 @@ void simple_hash(unsigned char *str,int len,unsigned char* res) //djb2+ sdbm
|
|||||||
int i=0;
|
int i=0;
|
||||||
while(c = *str++,i++!=len)
|
while(c = *str++,i++!=len)
|
||||||
{
|
{
|
||||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
// hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||||
|
hash = ((hash << 5) + hash)^c; /* (hash * 33) ^ c */
|
||||||
hash2 = c + (hash2 << 6) + (hash2 << 16) - hash2;
|
hash2 = c + (hash2 << 6) + (hash2 << 16) - hash2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user