github.com/prysmaticlabs/prysm@v1.4.4/tools/analyzers/cryptorand/testdata/rand_new.go (about)

     1  package testdata
     2  
     3  import (
     4  	"math/rand"
     5  	mathRand "math/rand"
     6  	"time"
     7  )
     8  
     9  // UseRandNew --
    10  func UseRandNew() {
    11  	source := rand.NewSource(time.Now().UnixNano()) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
    12  	randGenerator := mathRand.New(source)           // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
    13  	start := uint64(randGenerator.Intn(32))
    14  	_ = start
    15  
    16  	source = rand.NewSource(time.Now().UnixNano()) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
    17  	randGenerator = rand.New(source)               // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
    18  }
    19  
    20  // UseWithoutSeed --
    21  func UseWithoutSeed() {
    22  	assignedIndex := rand.Intn(128) // want "crypto-secure RNGs are required, use CSPRNG or PRNG defined in github.com/prysmaticlabs/prysm/shared/rand"
    23  	_ = assignedIndex
    24  }