mirror of
https://github.com/Snawoot/hola-proxy.git
synced 2026-04-02 17:58:13 +00:00
33 lines
602 B
Go
33 lines
602 B
Go
package main
|
|
|
|
import (
|
|
crand "crypto/rand"
|
|
"math/big"
|
|
)
|
|
|
|
type secureRandomSource struct{}
|
|
|
|
var RandomSource secureRandomSource
|
|
|
|
var int63Limit = big.NewInt(0).Lsh(big.NewInt(1), 63)
|
|
var int64Limit = big.NewInt(0).Lsh(big.NewInt(1), 64)
|
|
|
|
func (_ secureRandomSource) Seed(_ int64) {
|
|
}
|
|
|
|
func (_ secureRandomSource) Int63() int64 {
|
|
randNum, err := crand.Int(crand.Reader, int63Limit)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return randNum.Int64()
|
|
}
|
|
|
|
func (_ secureRandomSource) Uint64() uint64 {
|
|
randNum, err := crand.Int(crand.Reader, int64Limit)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return randNum.Uint64()
|
|
}
|