// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //:build js && wasm // This implementation of crypto/rand takes its entropy from the host's // cryptographically secure generator (crypto.getRandomValues in the browser), // reached through crypto/internal/sysrand's wasm implementation. package rand import ( "io" "crypto/internal/sysrand" ) func _reader() io.Reader { return &reader{} } type reader struct{} func (r *reader) Read(b []byte) (n int32, err error) { if len(b) == 0 { return 0, nil } sysrand.Read(b) return int32(len(b)), nil }