Use crypto/rand.Read instead of math/rand.Read

As of Go 1.20, `math/rand.Read` is deprecated. In addition to that, it also
isn't recommended for use in combination with anything cryptographic.

I haven't replaced all `math/rand` with `crypto/rand` imports because there
are still some legitimate uses for the `math/rand` package in some places.

Signed-off-by: Neil Twigg <neil@nats.io>
This commit is contained in:
Neil Twigg
2023-06-20 11:51:15 +01:00
parent cda7bcd389
commit 1527000d1f
10 changed files with 42 additions and 39 deletions

View File

@@ -18,9 +18,9 @@ package test
import (
"context"
crand "crypto/rand"
"encoding/json"
"fmt"
"math/rand"
"net"
"net/url"
"os"
@@ -687,7 +687,7 @@ func TestNoRaceSlowProxy(t *testing.T) {
// Now test send BW.
const payloadSize = 64 * 1024
var payload [payloadSize]byte
rand.Read(payload[:])
crand.Read(payload[:])
// 5MB total.
bytesSent := (5 * 1024 * 1024)