simplifying dirhash to 64bit integer

This commit is contained in:
Chris Lu
2018-05-26 21:24:03 -07:00
parent 955eae3500
commit 87b3b84471
3 changed files with 40 additions and 14 deletions

View File

@@ -5,9 +5,28 @@ import (
"io"
)
// returns a 128 bit hash
func md5hash(dir string) []byte {
// returns a 64 bit big int
func hashToLong(dir string) (v int64) {
h := md5.New()
io.WriteString(h, dir)
return h.Sum(nil)
b := h.Sum(nil)
v += int64(b[0])
v <<= 8
v += int64(b[1])
v <<= 8
v += int64(b[2])
v <<= 8
v += int64(b[3])
v <<= 8
v += int64(b[4])
v <<= 8
v += int64(b[5])
v <<= 8
v += int64(b[6])
v <<= 8
v += int64(b[7])
return
}