mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-12 04:34:41 +04:00
Completes https://github.com/XTLS/Xray-core/pull/5067 --------- Co-authored-by: wwqgtxx <wwqgtxx@gmail.com>
19 lines
379 B
Go
19 lines
379 B
Go
// Package crypto provides common crypto libraries for Xray.
|
|
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
|
|
}
|
|
if from > to {
|
|
from, to = to, from
|
|
}
|
|
bigInt, _ := rand.Int(rand.Reader, big.NewInt(to-from))
|
|
return from + bigInt.Int64()
|
|
}
|