photoprism/pkg/rnd/bytes.go

14 lines
240 B
Go
Raw Normal View History

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
}