How can i generate a long hash of a String?

后端 未结 4 2012
没有蜡笔的小新
没有蜡笔的小新 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 21:52

    This code will calculate pretty good hash:

    String s = "some string";
    long hash = UUID.nameUUIDFromBytes(s.getBytes()).getMostSignificantBits();
    

提交回复
热议问题