edge/pkg/app/crypto.go

26 lines
441 B
Go

package app
import (
"crypto/rand"
"encoding/binary"
"github.com/pkg/errors"
)
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(errors.Wrap(err, "could not read number for random source"))
}
return v
}