npm.io
0.0.3 • Published 7 years ago

random-web

Licence
MIT
Version
0.0.3
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
3

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;
}