8)
9
10func RandomizeSize(minimalSize, maximumSize float64) decimal.Decimal {
11 rand.Seed(time.Now().Unix())12 x := rand.Float64()*(maximumSize-minimalSize) + minimalSize
13 r := decimal.NewFromFloat(x)
14 hundred := decimal.New(100, 1)
As math/rand
uses a statistical random number generator, using a low entropy
seed (such as constants and the current system time) may allow an attacker to
predict what the following number generated is.
package main
import (
"math/rand"
"time"
)
func main() {
rand.Seed(42) // constant seeds are bad
rand.Seed(time.Now().Unix()) // time based seeds don't have sufficient entropy
}