package util

import (
	"crypto/rand"
	"encoding/base64"
	"fmt"
)

// generateRandomStringURLSafe generates a base64 URL-safe random string of n bytes.
func generateRandomStringURLSafe(n int) (string, error) {
	bytes := make([]byte, n)
	_, err := rand.Read(bytes)
	if err != nil {
		return "", fmt.Errorf("failed to generate random bytes: %w", err)
	}
	return base64.RawURLEncoding.EncodeToString(bytes), nil
}
