Xray-core/common/crypto/crypto.go

16 lines
338 B
Go
Raw Normal View History

2020-11-25 19:01:53 +08:00
// Package crypto provides common crypto libraries for Xray.
2020-12-04 09:36:16 +08:00
package crypto // import "github.com/xtls/xray-core/common/crypto"
import (
"crypto/rand"
"math/big"
)
func RandBetween(from int64, to int64) int64 {
if from == to {
return from
}
bigInt, _ := rand.Int(rand.Reader, big.NewInt(to-from))
return from + bigInt.Int64()
}