080ba47a06
Change-Id: I6a419c62700c568254ff67ae5b73efed2fc98aa2
27 lines
517 B
Go
27 lines
517 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
|
|
}
|