fix: admin login session

This commit is contained in:
henry.chen
2025-07-25 13:35:06 +08:00
parent fd7981b4f9
commit c1d73f1a45
2 changed files with 14 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
package tools
import (
"crypto/rand"
"crypto/sha256"
"fmt"
"io"
@@ -128,3 +129,14 @@ func IgnoreHTMLTag(src string) string {
// 去除换行符
return regexpEnter.ReplaceAllString(src, "")
}
// CryptoRand random with crypto/rand
func CryptoRand(byteLen int) []byte {
buf := make([]byte, byteLen)
_, err := rand.Read(buf)
if err != nil {
panic(fmt.Sprintf("rand: error reading random bytes: %s", err))
}
return buf
}