14 lines
240 B
Go
14 lines
240 B
Go
|
package rnd
|
||
|
|
||
|
import "crypto/rand"
|
||
|
|
||
|
// RandomBytes returns cryptographically secure random bytes.
|
||
|
func RandomBytes(n int) ([]byte, error) {
|
||
|
b := make([]byte, n)
|
||
|
_, err := rand.Read(b)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return b, nil
|
||
|
}
|