mirror of
https://github.com/k3s-io/k3s.git
synced 2026-04-13 21:36:35 -04:00
15 lines
255 B
Go
15 lines
255 B
Go
package util
|
|
|
|
import (
|
|
cryptorand "crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func Random(size int) (string, error) {
|
|
token := make([]byte, size, size)
|
|
_, err := cryptorand.Read(token)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return hex.EncodeToString(token), err
|
|
}
|