seaweedfs/weed/filer2/abstract_sql/hashing.go

33 lines
399 B
Go
Raw Normal View History

package abstract_sql
import (
"crypto/md5"
"io"
)
2018-05-27 04:24:03 +00:00
// returns a 64 bit big int
func hashToLong(dir string) (v int64) {
h := md5.New()
io.WriteString(h, dir)
2018-05-27 04:24:03 +00:00
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
}