31 lines
505 B
Go
31 lines
505 B
Go
package util
|
|
|
|
import (
|
|
crand "crypto/rand"
|
|
mrand "math/rand"
|
|
)
|
|
|
|
type src struct{}
|
|
|
|
func (s src) Int63() int64 {
|
|
result := make([]byte, 8)
|
|
_, err := crand.Read(result)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return int64(result[0]&0x7F)<<56 |
|
|
int64(result[1])<<48 |
|
|
int64(result[2])<<40 |
|
|
int64(result[3])<<32 |
|
|
int64(result[4])<<24 |
|
|
int64(result[5])<<16 |
|
|
int64(result[6])<<8 |
|
|
int64(result[7])<<0
|
|
}
|
|
|
|
func (s src) Seed(seed int64) {
|
|
// We don't do seeds here.
|
|
}
|
|
|
|
var Rand = mrand.New(src{})
|