/
rnd.go
68 lines (58 loc) · 1.28 KB
/
rnd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
e "github.com/cinnabardk/allancorfix2/internal/errors"
"github.com/losalamos/rdrand"
"github.com/AndreasBriese/breeze"
"github.com/db47h/rand64"
//"github.com/tildeleb/cuckoo"
"github.com/db47h/rand64/xorshift"
"github.com/zephyrtronium/xer"
"math/rand"
"time"
)
func testRandom(){
test := Test{}
test.Breeze()
test.Rand64()
test.Xer()
}
func (_ Test) Random() {
r := rdrand.Uint64()
println(r)
}
func (_ Test)Breeze() {
//
// drain 1000 random bytes from chaos
//
var bmap128 breeze.BreezeCS128
err := bmap128.Init()
if err != nil {
e.InfoLog.Println(err)
panic(1)
}
resultI := make([]uint8, 70)
for i, _ := range resultI {
resultI[i] = uint8(bmap128.RandIntn()) >> 4
}
e.InfoLog.Println("Breeze Random: ", resultI)
}
func (_ Test)Rand64(){
const SEED1 = 1387366483214
var s rand64.Source64 = xorshift.New64star()
s.Seed64(SEED1)
r64 := rand64.New(s)
resultI := make([]uint8, 70)
for i, _ := range resultI {
resultI[i] = uint8(r64.Uint32()) >> 4
}
e.InfoLog.Println("Rand64 Random: ", resultI)
}
func (_ Test) Xer(){
var rng *rand.Rand
rng = rand.New(xer.New(time.Now().UnixNano(), 256))
resultI := make([]uint8, 70)
for i, _ := range resultI {
resultI[i] = uint8(rng.Uint32()) >> 4
}
e.InfoLog.Println("Xer Random: ", resultI)
}