From a2df3f114acbeaabc69b6b854c22dd21ead581b8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 16 May 2018 16:28:01 +0200 Subject: inital import --- crypto.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 crypto.go (limited to 'crypto.go') diff --git a/crypto.go b/crypto.go new file mode 100644 index 0000000..22e7cdf --- /dev/null +++ b/crypto.go @@ -0,0 +1,22 @@ +package main + +import ( + "crypto/rand" + "encoding/binary" +) + +type cryptoSource struct{} + +func (c cryptoSource) Seed(seed int64) {} + +func (c cryptoSource) Int63() int64 { + return int64(c.Uint64() &^ uint64(1<<63)) +} + +func (c cryptoSource) Uint64() uint64 { + var v uint64 + if err := binary.Read(rand.Reader, binary.BigEndian, &v); err != nil { + panic(err) + } + return v +} -- cgit v1.2.3