Hash collision in Utils.hashStr
See original GitHub issueHi,
I just encountered a hash collision when registering a new class. The problem is line 52 of Serializer.js with Utils.hashStr. It returns the same hash (37) for two different strings: “Tile” & “NetworkedEventCollection”
Here is the test code :
import Utils from 'lance/lib/Utils';
console.log(Utils.hashStr('NetworkedEventCollection'));
console.log(Utils.hashStr('Tile'));
For now, hopefully, we can pass a classId to the registerClass method. Shouldn’t be hard to fix 😃 Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why is there no collision in a HashMap when different keys ...
You are confusing a collision - case when hashes of keys are the same (or to be precise, when hashes are withing the...
Read more >Issue 13703: Hash collision security issue - Python tracker
msg150522 ‑ (view) Author: Barry A. Warsaw (barry) * Date: 2012‑01‑03 19:36
msg150525 ‑ (view) Author: Christian Heimes (christian.heimes) * Date: 2012‑01‑03 20:19
msg150526 ‑...
Read more >How does Python's built-in hash() function compare to other ...
For integers and floats hash collisions wont happen - if two values have the same hash, they will have the same value. For...
Read more >Hashtable (Java Platform SE 8 ) - Oracle Help Center
java.util. ... This class implements a hash table, which maps keys to values. ... Note that the hash table is open: in the...
Read more >How to Implement a Hash Map in JavaScript | by Jake Zhang
Additionally, we've supplied the below hashing function hashStr . It tries to avoid collision, but is not perfect. It takes in a string...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some investigations, I found that the problems resides in the poor precision of the hash. So, instead of 8 bits (default in hashStr), it can be changed to 16 and accordingly in serialize/deserialize. Precision seems much better with this fix 😃
A simple workaround is to change the name of the class. So renaming
'Agent'
to'AgentObj'
works around the issue until the hash function is fixed