mirror of
https://github.com/livekit/livekit.git
synced 2026-04-17 03:55:39 +00:00
20 lines
310 B
Go
20 lines
310 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"io"
|
|
|
|
"github.com/lytics/base62"
|
|
)
|
|
|
|
func RandomSecret() string {
|
|
// 256 bit secret
|
|
buf := make([]byte, 32)
|
|
_, err := io.ReadFull(rand.Reader, buf)
|
|
// cannot error
|
|
if err != nil {
|
|
panic("could not read random")
|
|
}
|
|
return base62.StdEncoding.EncodeToString(buf)
|
|
}
|