goext/langext/rand.go
2022-10-27 17:55:27 +02:00

16 lines
193 B
Go

package langext
import (
"crypto/rand"
"io"
)
func RandBytes(size int) []byte {
b := make([]byte, size)
_, err := io.ReadFull(rand.Reader, b)
if err != nil {
panic(err)
}
return b
}