Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael) Upstream-commit: 5428964400ece4cd79cc5d482307df5e8913469f Component: engine
16 lines
286 B
Go
16 lines
286 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"io"
|
|
)
|
|
|
|
func GenerateRandomName(prefix string, size int) (string, error) {
|
|
id := make([]byte, 32)
|
|
if _, err := io.ReadFull(rand.Reader, id); err != nil {
|
|
return "", err
|
|
}
|
|
return prefix + hex.EncodeToString(id)[:size], nil
|
|
}
|