27 lines
516 B
Go
27 lines
516 B
Go
|
// Copyright (C) 2019 Storj Labs, Inc.
|
||
|
// See LICENSE for copying information.
|
||
|
|
||
|
package audit
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"encoding/binary"
|
||
|
)
|
||
|
|
||
|
// cryptoSource implements the math/rand Source interface using crypto/rand
|
||
|
type cryptoSource struct{}
|
||
|
|
||
|
func (s cryptoSource) Seed(seed int64) {}
|
||
|
|
||
|
func (s cryptoSource) Int63() int64 {
|
||
|
return int64(s.Uint64() & ^uint64(1<<63))
|
||
|
}
|
||
|
|
||
|
func (s cryptoSource) Uint64() (v uint64) {
|
||
|
err := binary.Read(rand.Reader, binary.BigEndian, &v)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return v
|
||
|
}
|