use fnv instead of md5

This commit is contained in:
2022-03-25 20:40:57 -07:00
parent 4d3bbc0c88
commit f101db6d58
3 changed files with 14 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package go_colorhash
import (
"crypto/md5"
"encoding/binary"
"hash/fnv"
"io"
)
@@ -10,7 +11,7 @@ const MaxUint = ^uint(0)
const MaxInt = int(MaxUint >> 1)
func HashString(s string) int {
h := md5.New()
h := fnv.New64()
io.WriteString(h, s)
hashb := h.Sum(nil)
hashb = hashb[len(hashb)-8:]