8 var Reader io.Reader = &randEntropy{}
10 type randEntropy struct {
13 func (*randEntropy) Read(bytes []byte) (n int, err error) {
14 readBytes := GetEntropyCSPRNG(len(bytes))
15 copy(bytes, readBytes)
16 return len(bytes), nil
19 func GetEntropyCSPRNG(n int) []byte {
20 mainBuff := make([]byte, n)
21 _, err := io.ReadFull(crand.Reader, mainBuff)
23 panic("reading from crypto/rand failed: " + err.Error())