Skip to main content
Glama
random.go561 B
package util import ( "crypto/rand" "encoding/hex" ) // GenerateRandomString generates a random string of the specified length using hex encoding. func GenerateRandomString(length int) string { bytes := make([]byte, (length+1)/2) // Need half the bytes for hex encoding if _, err := rand.Read(bytes); err != nil { // Fallback to a simple timestamp-based approach if crypto/rand fails return hex.EncodeToString([]byte("fallback"))[:length] } result := hex.EncodeToString(bytes) if len(result) > length { return result[:length] } return result }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/babelcloud/gru-sandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server