How can i generate a long hash of a String?

后端 未结 4 2029
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 21:27

I have a java applciation in which I want to generate long ids for strings (in order to store those strings in neo4j). In order to avoid data duplication, I wou

4条回答
  •  忘掉有多难
    2021-01-04 22:04

    There are many answers, try the following:

    • http://stackoverflow.com/questions/415953/generate-md5-hash-in-java EDIT: removed, I've missed the long requirement. Mea culpa.
    • http://en.wikipedia.org/wiki/Perfect_hash_function

    Or, as suggested before, check out the sources.

    PS. One more technique is to maintain a dictionary of strings: since you're unlikely to get 264 strings any time soon, you can have perfect mapping. Note though that that mapping may as well become a major bottleneck.

提交回复
热议问题