all: Use crypt/rand through its buffered version, but not in benchmarks (#7420)

This commit is contained in:
greatroar
2021-03-02 19:17:20 +01:00
committed by GitHub
parent 55d5e03639
commit 56b5352f64
6 changed files with 22 additions and 10 deletions
+7 -3
View File
@@ -9,13 +9,17 @@
package rand
import (
cryptoRand "crypto/rand"
"io"
mathRand "math/rand"
"reflect"
)
// Reader is the standard crypto/rand.Reader, re-exported for convenience
var Reader = cryptoRand.Reader
// Reader is the standard crypto/rand.Reader with added buffering.
var Reader = defaultSecureSource
func Read(p []byte) (int, error) {
return io.ReadFull(defaultSecureSource, p)
}
// randomCharset contains the characters that can make up a rand.String().
const randomCharset = "2345679abcdefghijkmnopqrstuvwxyzACDEFGHJKLMNPQRSTUVWXYZ"