Created
July 10, 2016 10:20
-
-
Save bgnori/072d05b837ee6edcb9084ff879721396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/rand" | |
"encoding/base64" | |
"encoding/binary" | |
"fmt" | |
"github.com/seehuhn/mt19937" | |
) | |
const ( | |
N64 = 312 | |
NByte = 2496 | |
) | |
func main() { | |
b := make([]byte, NByte) | |
n, err := rand.Reader.Read(b) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("read %d bytes\n", n) | |
encoded := base64.StdEncoding.EncodeToString(b) | |
fmt.Println(encoded) | |
u := make([]uint64, N64) | |
for i := 0; i < N64; i++ { | |
u[i], _ = binary.Uvarint(b[i*8 : (i+1)*8]) | |
} | |
mt := mt19937.New() | |
mt.SeedFromSlice(u) | |
fmt.Println(mt.Int63()) | |
fmt.Println(mt.Int63()) | |
fmt.Println(mt.Int63()) | |
fmt.Println(mt.Int63()) | |
fmt.Println(mt.Int63()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment