mirror of https://github.com/k3s-io/k3s
16 lines
255 B
Go
16 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
|
||
|
}
|