first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package helper
import (
"crypto/md5"
"encoding/hex"
"math/rand"
"strconv"
"time"
)
// 获取随机盐值
func PasswordSalt() string {
randInt := rand.New(rand.NewSource(time.Now().UnixNano()))
return strconv.Itoa(randInt.Int() % 10000)
}
// 计算加密后的密码
func PasswordWithMd5(password, salt string) string {
h := md5.New()
h.Write([]byte(password + salt))
cipherStr := h.Sum(nil)
return hex.EncodeToString(cipherStr)
}