scalahashstring-hashing

64bit (Long) hash of a string in Scala


I need a uniform string hash that produces longs, for use in a bloom filter. Where can I find an algorithm or a library for this? Thanks.


Solution

  • You can do what String.hashCode does, just using longs:

     val code = string.foldLeft(0L) { case (code, c) => 31*code + c }