An open API service indexing awesome lists of open source software.

https://github.com/jedisct1/tinygo-wasi_rand

crypto/rand for TinyGo/WASI
https://github.com/jedisct1/tinygo-wasi_rand

crypto csprng tinygo wasi wasm

Last synced: 7 months ago
JSON representation

crypto/rand for TinyGo/WASI

Awesome Lists containing this project

README

          

# A CSPRNG for TinyGo/WebAssembly (WASI)

TinyGo doesn't support `crypto/rand` yet, which is quite of a deal breaker for many cryptographic operations.

This module implements `wasi_rand`, a secure random number generator for TinyGo when used in a WebAssembly/WASI environment.

Usage:

```go
import (
wasi_rand "github.com/jedisct1/tinygo-wasi_rand"
)

func main() {
var key [32]byte
if err := wasi_rand.Read(key[:]); err != nil {
// panic: no entropy source available
}
}
```

`wasi_rand.Read()` can fill buffers of arbitrary sizes.