edge/pkg/app/crypto.go

26 lines
441 B
Go
Raw Permalink Normal View History

2023-02-09 12:16:36 +01:00
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
}