crypto.go 338 B

123456789101112131415
  1. // Package crypto provides common crypto libraries for Xray.
  2. package crypto // import "github.com/xtls/xray-core/common/crypto"
  3. import (
  4. "crypto/rand"
  5. "math/big"
  6. )
  7. func RandBetween(from int64, to int64) int64 {
  8. if from == to {
  9. return from
  10. }
  11. bigInt, _ := rand.Int(rand.Reader, big.NewInt(to-from))
  12. return from + bigInt.Int64()
  13. }