Files
rands/bytes.go

15 lines
236 B
Go

package rands
import "crypto/rand"
// Bytes generates a byte slice of n number of random bytes.
func Bytes(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
return nil, err
}
return b, nil
}