romanornr / autodealer

Audit the random number generation source (rand) GSC-G404
Security
Minor
4 months ago3 years old
Use of weak random number generator (math/rand instead of crypto/rand)
18func RandFloats(min, max float64, n int) []float64 {
19	res := make([]float64, n)
20	for i := range res {
21		res[i] = min + rand.Float64()*(max-min)22	}
23	return res
24}
Use of weak random number generator (math/rand instead of crypto/rand)
 9
10func RandomizeSize(minimalSize, maximumSize float64) decimal.Decimal {
11	rand.Seed(time.Now().Unix())
12	x := rand.Float64()*(maximumSize-minimalSize) + minimalSize13	r := decimal.NewFromFloat(x)
14	hundred := decimal.New(100, 1)
15	return r.Mul(hundred).Div(hundred)