crypto.go 379 B

123456789101112131415161718
  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. if from > to {
  12. from, to = to, from
  13. }
  14. bigInt, _ := rand.Int(rand.Reader, big.NewInt(to-from))
  15. return from + bigInt.Int64()
  16. }