aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bytes.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util/bytes.go')
-rw-r--r--weed/util/bytes.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/weed/util/bytes.go b/weed/util/bytes.go
index 9c7e5e2cb..d9e462693 100644
--- a/weed/util/bytes.go
+++ b/weed/util/bytes.go
@@ -74,3 +74,20 @@ func HashStringToLong(dir string) (v int64) {
return
}
+
+func HashToInt32(data []byte) (v int32) {
+ h := md5.New()
+ h.Write(data)
+
+ b := h.Sum(nil)
+
+ v += int32(b[0])
+ v <<= 8
+ v += int32(b[1])
+ v <<= 8
+ v += int32(b[2])
+ v <<= 8
+ v += int32(b[3])
+
+ return
+}