k3s/vendor/github.com/bhendo/go-powershell/utils/rand.go

21 lines
284 B
Go
Raw Normal View History

2019-09-05 18:55:53 +00:00
// Copyright (c) 2017 Gorillalabs. All rights reserved.
package utils
import (
"crypto/rand"
"encoding/hex"
)
func CreateRandomString(bytes int) string {
c := bytes
b := make([]byte, c)
_, err := rand.Read(b)
if err != nil {
panic(err)
}
return hex.EncodeToString(b)
}