aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-08 22:30:38 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-08 22:30:38 -0700
commit00b993a234038e0c70eab4f307ae9c89e6771a83 (patch)
tree9fb0ed0a303b8814d7ef162fe7e371e48c11e0b6
parented98223b08dcb192aa047864af4aa67874e0a54e (diff)
downloadseaweedfs-00b993a234038e0c70eab4f307ae9c89e6771a83.tar.xz
seaweedfs-00b993a234038e0c70eab4f307ae9c89e6771a83.zip
add util for md5
-rw-r--r--weed/util/bytes.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/weed/util/bytes.go b/weed/util/bytes.go
index d9e462693..d72d199f8 100644
--- a/weed/util/bytes.go
+++ b/weed/util/bytes.go
@@ -2,6 +2,7 @@ package util
import (
"crypto/md5"
+ "fmt"
"io"
)
@@ -91,3 +92,9 @@ func HashToInt32(data []byte) (v int32) {
return
}
+
+func Md5(data []byte) string {
+ hash := md5.New()
+ hash.Write(data)
+ return fmt.Sprintf("%x", hash.Sum(nil))
+}