random-web

Obtain cryptographically strong random bytes. For Browser.

Usage no npm install needed!

<script type="module">
  import randomWeb from 'https://cdn.skypack.dev/random-web';
</script>

README

Random-web

npm version dependencies Status

  • It allows to obtain cryptographically strong random bytes.
  • Suitable for browser usage.
  • Dependency free

Usage

With Typescript

import {Random} from 'random-web';

Random.buffer(16) // return ArrayBuffer
Random.bytes(16) // return Uint8Array


// The Random provider interface

class Random {
    static buffer(size: number): ArrayBuffer;
    static bytes(size: number): Uint8Array;
    static fill(view: ArrayBufferView): ArrayBufferView;
    static string(length: number): string;
    static salt(bytes?: number): ArrayBuffer;
}