I need to create a hash based on a string, and found the random_shash VEX function. But this little note at the end of the doc page is a little disconcerting:
“NOTE: Two different strings may hash to the same value.”
That defeats the purpose a bit, and I need to guarantee the results are unique per unique string. Any details on which strings may result in the same hash value? Is this because of the limitations of 32-bit integers?
Thanks!
random_shash may not be unique?
1276 2 0- bsilva
- Member
- 8 posts
- Joined: Aug. 2011
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
- BabaJ
- Member
- 2017 posts
- Joined: Sept. 2015
- Offline
http://www.asciitable.com/ [www.asciitable.com]
Characters in a string each have there own corresponding numeric value;
As such different combinations can result in the same overall numeric value e.g.,
…
b = 98
c = 99
e = 101
f = 102
…
so the string “ce” ends up being of the same value “bf”, i.e. 200 = 99 + 101 = 98 + 102
Of course I could be wrong…but this is my guess of what's going on.
Characters in a string each have there own corresponding numeric value;
As such different combinations can result in the same overall numeric value e.g.,
…
b = 98
c = 99
e = 101
f = 102
…
so the string “ce” ends up being of the same value “bf”, i.e. 200 = 99 + 101 = 98 + 102
Of course I could be wrong…but this is my guess of what's going on.
-
- Quick Links