Пример #1
0
func randomInt(max *big.Int) (int, error) {
	rand, err := rand.Int(rand.Reader, max)
	if err != nil {
		return 0, err
	}

	return int(rand.Int64()), nil
}
Пример #2
0
func newRandomInt(max *big.Int) int {
	rand, err := rand.Int(rand.Reader, max)
	if err != nil {
		// Fallback to pseudo-random
		return pseudoRand.Intn(int(max.Int64()))
	}
	return int(rand.Int64())
}