19 lines
485 B
Go
19 lines
485 B
Go
package service
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// GenerateSubscriptionToken returns a 32-character hex token compatible with
|
|
// XBoard-style subscription URLs.
|
|
func GenerateSubscriptionToken() string {
|
|
buf := make([]byte, 16)
|
|
if _, err := rand.Read(buf); err != nil {
|
|
// Fall back to zero-value encoding only in the unlikely event random
|
|
// source fails; callers still get a stable-length token.
|
|
return hex.EncodeToString(buf)
|
|
}
|
|
return hex.EncodeToString(buf)
|
|
}
|