I have a hash function which returns back to me an unsigned integer uint32_t
given a char*
as shown below:
uint32_t key_hashing(const char* key)
{
return hashing(key, 0x7fffffff, 101);
}
uint32_t hashing(const char* word, int tsize, uint32_t seed)
{
char c;
uint32_t h = seed;
for ( ; (c=*word) != '\0'; ++word)
{
h ^= ( (h<<5) + c + (h >> 2) );
}
return ((uint32_t)(h&0x7fffffff) % tsize);
}
Now I want to do opposite: Let's say I have been given uint32_t
number, I want to revert back to its original form which was in char*
earlier. How can I do that? Basically my uint32_t
number should give me back the original char* that was passed.
由于哈希冲突,这种方法行不通:字节数组可以有任意多种排列,但只有固定数量的不同uint32_t
,因此一堆不同的char *
将哈希到相同的 uint32_t
值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.