TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Abnormal String Hashing

52 pointsby r4umover 5 years ago

6 comments

saagarjhaover 5 years ago
If you&#x27;re curious on how to avoid this in your applications, take a look at universal hashing: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Universal_hashing" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Universal_hashing</a>
评论 #21197542 未加载
hinkleyover 5 years ago
Do all of those lookup tables for powers of 31 work once integer overflow happens?
评论 #21201355 未加载
rurbanover 5 years ago
He really didn&#x27;t understand Java&#x27;s take on this. Being zero-insensitive obviously is totally insecure. Java knew that. But Java decided to fight those kind of attacks better than most others. Java has a still trivial insecure hash function, which it decided to keep, because of an API blunder. But they convert the collisions from a linked list to a tree on too many collisions which indicate an active attack. Those attacks are rare, the common case is still fast.<p>Zero-insensitivity would have been fixable trivially, perl fixed that with 5.18, but they couldn&#x27;t, so they came up with a proper and much better fix. Unlike perl and everyone else.
评论 #21201886 未加载
hinkleyover 5 years ago
I&#x27;m looking at all of the lookup tables in that code and wondering how much slower it would be to do a depth-first search and calculate as you went.<p>And then with a trie thrown in.
sorokodover 5 years ago
This is fun, but with the test code running 10 million iterations to generate &quot;slower&quot; numbers, is this of practical interest?
评论 #21199835 未加载
jepcommenterover 5 years ago
Arbitrary length string of null characters also produces zero hash, e.g.: System.out.println(&quot;\0\0\0\0\0&quot;.hashCode());