Skip to content

Instantly share code, notes, and snippets.

@andre3k1
Created July 30, 2013 17:42
Show Gist options
  • Save andre3k1/6115120 to your computer and use it in GitHub Desktop.
Save andre3k1/6115120 to your computer and use it in GitHub Desktop.
Truncate 128-byte md5 hash to a 64-byte long avoiding collisions.
def md5ToLong(md5: String) = {
var hash = 1125899906842597L
for (n <- 0 until md5.length) hash = 31 * hash + md5.charAt(n)
hash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment