aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bytes.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-08-28 23:48:48 -0700
committerChris Lu <chris.lu@gmail.com>2020-08-28 23:48:48 -0700
commitca658a97c5248ba099356b006f0b341af53b0816 (patch)
tree8b59defed9a417c4fa2e9346a23cd8a64e851852 /weed/util/bytes.go
parent63ad1abccec691d2204b8dc63109ffeead0b0eed (diff)
downloadseaweedfs-ca658a97c5248ba099356b006f0b341af53b0816.tar.xz
seaweedfs-ca658a97c5248ba099356b006f0b341af53b0816.zip
add signatures to messages to avoid double processing
Diffstat (limited to 'weed/util/bytes.go')
-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 890d50586..82e4ddeef 100644
--- a/weed/util/bytes.go
+++ b/weed/util/bytes.go
@@ -2,6 +2,7 @@ package util
import (
"crypto/md5"
+ "crypto/rand"
"encoding/base64"
"fmt"
"io"
@@ -135,3 +136,9 @@ func Base64Md5ToBytes(contentMd5 string) []byte {
}
return data
}
+
+func RandomInt32() int32 {
+ buf := make([]byte, 4)
+ rand.Read(buf)
+ return int32(BytesToUint32(buf))
+}