Added twc_hash_tox_id.
This commit is contained in:
parent
73980b1042
commit
a5c4023f9e
@ -168,3 +168,18 @@ twc_uint32_reverse_bytes(uint32_t num)
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash a Tox ID of size TOX_CLIENT_ID_SIZE bytes using a modified djb2 hash.
|
||||||
|
*/
|
||||||
|
unsigned long long
|
||||||
|
twc_hash_tox_id(const uint8_t *tox_id)
|
||||||
|
{
|
||||||
|
unsigned long long hash = 5381;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < TOX_CLIENT_ID_SIZE; ++i)
|
||||||
|
hash ^= (hash << 5) + (hash >> 2) + tox_id[i];
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -51,5 +51,8 @@ twc_get_friend_id_short(Tox *tox, int32_t friend_number);
|
|||||||
uint32_t
|
uint32_t
|
||||||
twc_uint32_reverse_bytes(uint32_t num);
|
twc_uint32_reverse_bytes(uint32_t num);
|
||||||
|
|
||||||
|
unsigned long long
|
||||||
|
twc_hash_tox_id(const uint8_t *tox_id);
|
||||||
|
|
||||||
#endif // TOX_WEECHAT_UTILS_H
|
#endif // TOX_WEECHAT_UTILS_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user