NIST Randomness Beacon (https://beacon.nist.gov/home) api wrapper
NIST Randomness Beacon (https://beacon.nist.gov/home) API wrapper
WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS.
import (
"fmt"
"github.com/sherlach/go-nist-beacon"
"math/big"
"math/rand"
)
func main() {
r, err := beacon.LastRecord()
if err != nil {
panic(err)
}
i := new(big.Int)
ra := rand.New(rand.NewSource(i.Rsh(&r.SeedValue, 448).Int64()))
fmt.Println(ra.Int(), ra.Int(), i.Rsh(&r.SeedValue, 448).Int64(), r.SeedValue)
}
Using the same seed value the random numbers generated are the same.
A much simpler version of the same would be:
import (
"fmt"
"github.com/sherlach/go-nist-beacon"
)
func main() {
ra, err := beacon.NewUpdatedRand()
if err != nil {
panic(err)
}
fmt.Println(ra.Int(), ra.Int())
}