Created
July 30, 2013 17:42
-
-
Save andre3k1/6115120 to your computer and use it in GitHub Desktop.
Truncate 128-byte md5 hash to a 64-byte long avoiding collisions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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