summaryrefslogtreecommitdiff
path: root/crypto.go
diff options
context:
space:
mode:
Diffstat (limited to 'crypto.go')
-rw-r--r--crypto.go22
1 files changed, 22 insertions, 0 deletions
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
+}