summaryrefslogtreecommitdiff
path: root/crypto.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-05-16 16:28:01 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-05-16 16:28:01 +0200
commita2df3f114acbeaabc69b6b854c22dd21ead581b8 (patch)
tree990d5f6e174a6c7cb3f9eaba34ebbb63eef7c9ba /crypto.go
inital import
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
+}