Home | History | Annotate | Download | only in rand
      1 // Copyright 2010 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // Package rand implements a cryptographically secure
      6 // pseudorandom number generator.
      7 package rand
      8 
      9 import "io"
     10 
     11 // Reader is a global, shared instance of a cryptographically
     12 // strong pseudo-random generator.
     13 //
     14 // On Linux, Reader uses getrandom(2) if available, /dev/urandom otherwise.
     15 // On OpenBSD, Reader uses getentropy(2).
     16 // On other Unix-like systems, Reader reads from /dev/urandom.
     17 // On Windows systems, Reader uses the CryptGenRandom API.
     18 var Reader io.Reader
     19 
     20 // Read is a helper function that calls Reader.Read using io.ReadFull.
     21 // On return, n == len(b) if and only if err == nil.
     22 func Read(b []byte) (n int, err error) {
     23 	return io.ReadFull(Reader, b)
     24 }
     25