This commit is contained in:
chowyu08
2017-08-25 21:29:03 +08:00
parent 5c6e136c2b
commit 80e118728d
8 changed files with 342 additions and 46 deletions

View File

@@ -2,7 +2,12 @@ package broker
import (
"bytes"
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"errors"
"io"
"reflect"
"strings"
"time"
@@ -128,3 +133,14 @@ func equal(k1, k2 interface{}) bool {
}
return false
}
func GenUniqueId() string {
b := make([]byte, 48)
if _, err := io.ReadFull(rand.Reader, b); err != nil {
return ""
}
h := md5.New()
h.Write([]byte(base64.URLEncoding.EncodeToString(b)))
return hex.EncodeToString(h.Sum(nil))
// return GetMd5String()
}