To produce deterministic randomization for subsequent requests of clients I need to seed a random generator based on an UUID.
Is there a good way for doing this? The approach I am currently considering taking would be:
number := new(big.Int)
target := new(big.Int)
number.SetBytes(uuid.Bytes())
seed := number.Mod(target, big.NewInt(math.MaxInt64)).Int64()
Which is flawed in the sense that it makes collisions more likely but okay right now given there are only few requests coming in.
Aucun commentaire:
Enregistrer un commentaire