-1

I am trying to generate an entropy using crypto/rand instead of math/rand, and my entropy needs to be of type io.Reader.

//using math/rand

src := mathrand.NewSource(123)
entropy := mathrand.New(src)

I would appreciate all the suggestions!

1 Answers1

2

It's right at the top of the package doc: https://pkg.go.dev/crypto/rand#pkg-variables

Reader is a global, shared instance of a cryptographically secure random number generator.

Just use rand.Reader.

Adrian
  • 42,911
  • 6
  • 107
  • 99