Files
openteam/server/internal/pkg/rand/rand.go
T
SakurasanandClaude Sonnet 5 d0e31b198f feat(server): API relay gateway backend M0-M4
Gin + GORM + pure-Go SQLite. Users/auth (JWT), API key management with
quotas, proxy gateway with weighted channel failover and health checks,
usage/billing ledger, cross-protocol conversion (Anthropic Messages /
OpenAI Chat Completions / OpenAI Responses), and channel/model admin API.
Channels declare native API formats and auto-convert the rest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-15 21:05:02 +08:00

22 lines
466 B
Go

package rand
import (
crand "crypto/rand"
"math/big"
)
const base62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
// Base62 returns a cryptographically random base62 string of length n.
func Base62(n int) (string, error) {
out := make([]byte, n)
for i := range out {
idx, err := crand.Int(crand.Reader, big.NewInt(int64(len(base62))))
if err != nil {
return "", err
}
out[i] = base62[idx.Int64()]
}
return string(out), nil
}