jedisct1 / tinygo-wasi_rand

crypto/rand for TinyGo/WASI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

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.

About

crypto/rand for TinyGo/WASI

License:MIT License


Languages

Language:Go 100.0%