This commit is contained in:
blankhex committed 2026-10-21 19:41:26 +03:00
commit 97dc0a3570
78 files changed
+7054

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
package csrf
import (
"crypto/rand"
"encoding/base64"
"log/slog"
)
func generateToken(length int) (string, error) {
b := make([]byte, length)
_, err := rand.Read(b)
if err != nil {
slog.Error("generate csrf token", slog.String("op", "service.generateToken"), slog.Any("error", err))
return "", ErrInternal
}
return base64.RawURLEncoding.EncodeToString(b), nil
}