Files
wazero/internal/platform/crypto.go
Crypt Keeper 9414b0bb74 Switches default random source to deterministic (#736)
This changes the default random source to provide deterministic values
similar to how nanotime and walltime do. This also prevents any worries
about if wasm can deplete the host's underlying source of entropy.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-08-06 17:47:50 +08:00

18 lines
420 B
Go

package platform
import (
"io"
"math/rand"
)
// seed is a fixed seed value for NewFakeRandSource.
//
// Trivia: While arbitrary, 42 was chosen as it is the "Ultimate Answer" in
// the Douglas Adams novel "The Hitchhiker's Guide to the Galaxy."
const seed = int64(42)
// NewFakeRandSource returns a deterministic source of random values.
func NewFakeRandSource() io.Reader {
return rand.New(rand.NewSource(seed))
}