https://github.com/tmpfs/wasm-rand
Generate random values via WASM
https://github.com/tmpfs/wasm-rand
Last synced: about 1 year ago
JSON representation
Generate random values via WASM
- Host: GitHub
- URL: https://github.com/tmpfs/wasm-rand
- Owner: tmpfs
- Created: 2021-11-29T01:08:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T06:13:09.000Z (over 4 years ago)
- Last Synced: 2025-01-05T02:12:15.984Z (over 1 year ago)
- Language: JavaScript
- Size: 103 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RNG in WASM
Demo for generating random values in WASM via `Crypto.getRandomValues()` (see [webcrypto](https://github.com/w3c/webcrypto/)).
The `main` branch tests using `rand@0.8` with `getrandom@0.2` using multiple threads enabled using [wasm-bindgen-rayon](https://github.com/GoogleChromeLabs/wasm-bindgen-rayon).
For single-threaded versions see the `rand-0.8` and `rand-0.6.5` (older `wasm-bindgen` feature) branches.
## Prerequisites
* `rust@1.54.0`
* `wasm-pack@0.9.1`
* `node@14.17.0`
## Setup
```
make setup
```
## Serve
```
# Compile the webassembly module
make wasm
# Start the client on http://localhost:8080
make client
```
Now visit `http://localhost:8080`.
## Development
During development you should link the WASM module:
```
cd wasm/pkg && yarn link
cd client && yarn link wasm-rand
```