goext/langext/rand.go

16 lines
193 B
Go
Raw Normal View History

2022-10-27 16:48:26 +02:00
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
}