feat: 优化web

This commit is contained in:
2026-04-23 18:58:13 +08:00
commit 544a2f3428
160 changed files with 27327 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
package security
import (
"crypto/rand"
"encoding/base64"
)
// RandomURLSafe 生成 URL-safe 随机串(用于 opaque token、authorization code 等)。
func RandomURLSafe(nBytes int) (string, error) {
b := make([]byte, nBytes)
if _, err := rand.Read(b); err != nil {
return "", err
}
return base64.RawURLEncoding.EncodeToString(b), nil
}