mirror of
https://github.com/jimeh/rands.git
synced 2026-02-19 11:26:38 +00:00
15 lines
236 B
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
|
|
}
|