From 00b993a234038e0c70eab4f307ae9c89e6771a83 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 8 Apr 2020 22:30:38 -0700 Subject: [PATCH] add util for md5 --- weed/util/bytes.go | 7 +++++++ 1 file changed, 7 insertions(+) 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)) +}