修改了分享嘛
This commit is contained in:
@@ -7,7 +7,10 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
mathRand "math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Encrypt 加密函数
|
||||
@@ -88,3 +91,10 @@ func hashKey(key string) []byte {
|
||||
hash := sha256.Sum256([]byte(key))
|
||||
return hash[:]
|
||||
}
|
||||
|
||||
// GenerateUniqueCode 生成6位数唯一码
|
||||
func GenerateUniqueCode() string {
|
||||
mathRand.Seed(time.Now().UnixNano())
|
||||
code := fmt.Sprintf("%06d", mathRand.Intn(999999))
|
||||
return code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user