Standard library / crypto/rand
crypto/rand.Reader
Shared cryptographically secure randomness source. Use it without replacing the global variable. Error handling is required on the Go 1.23.2 baseline. Do not print secret bytes. Expected stdout: '16 true\n'.
Formal Syntax & Structure
go syntaxgo
var Reader io.ReaderWorking Example
Example Snippetgo
package main
import ( "crypto/rand" "fmt" "io")
func main() { b := make([]byte, 16); n, e := io.ReadFull(rand.Reader, b); fmt.Println(n, e == nil) }