MCPcopy
hub / github.com/caddyserver/caddy / GenerateRandomBytes

Function GenerateRandomBytes

caddytest/integration/stream_test.go:415–424  ·  view source on GitHub ↗

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

(n int)

Source from the content-addressed store, hash-verified

413// number generator fails to function correctly, in which
414// case the caller should not continue.
415func GenerateRandomBytes(n int) ([]byte, error) {
416 b := make([]byte, n)
417 _, err := rand.Read(b)
418 // Note that err == nil only if we read len(b) bytes.
419 if err != nil {
420 return nil, err
421 }
422
423 return b, nil
424}
425
426// GenerateRandomString returns a securely generated random string.
427// It will return an error if the system's secure random

Callers 1

GenerateRandomStringFunction · 0.85

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected