Files
wazero/internal/gojs/testdata/crypto/main.go
Crypt Keeper 3477e61aed Adds gojs for Go generated Wasm (#621)
This adds an experimental package gojs which implements the host side of Wasm compiled by GOARCH=wasm GOOS=js go build -o X.wasm X.go

This includes heavy disclaimers, in part inherited by Go's comments https://github.com/golang/go/blob/go1.19/src/syscall/js/js.go#L10-L11
Due to this many will still use TinyGo instead.

That said, this is frequently asked for and has interesting features including reflection and HTTP client support.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-08-26 13:43:21 +08:00

19 lines
272 B
Go

package crypto
import (
"crypto/rand"
"encoding/hex"
"fmt"
"log"
)
func Main() {
b := make([]byte, 5)
if n, err := rand.Read(b); err != nil {
log.Panicln(err)
} else if n != 5 {
log.Panicln("expected 5, but have ", n)
}
fmt.Println(hex.EncodeToString(b))
}