修改了分享嘛

This commit is contained in:
2024-12-10 14:50:55 +08:00
parent 14f4314982
commit 38ce98fada
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -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
}