summaryrefslogtreecommitdiff
path: root/crypto.go
blob: 22e7cdf7bae691ee7075ae4dc98e9c01ba79c8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
}