summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csrand/csrand.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/csrand/csrand.go b/csrand/csrand.go
index 1700b02..5a86da0 100644
--- a/csrand/csrand.go
+++ b/csrand/csrand.go
@@ -35,8 +35,8 @@ package csrand
import (
cryptRand "crypto/rand"
+ "encoding/binary"
"fmt"
- "math/big"
"math/rand"
)
@@ -52,12 +52,15 @@ type csRandSource struct {
}
func (r csRandSource) Int63() int64 {
- ret, err := cryptRand.Int(cryptRand.Reader, big.NewInt(int64((1<<63)-1)))
+ var src [8]byte
+ err := Bytes(src[:])
if err != nil {
panic(err)
}
+ val := binary.BigEndian.Uint64(src[:])
+ val &= (1<<63 - 1)
- return ret.Int64()
+ return int64(val)
}
func (r csRandSource) Seed(seed int64) {