0.0.2 • Published 7 years ago

secure-random-value v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

secure-random-value Travis CI Status NPM version

Generates cryptographically secure random values

Using Secure Random Value

1. Install as a dependency

yarn add secure-random-value

2. Import package

import { RandomString } from 'secure-random-string';

3. Get a random value

let random_string = await RandomString();

Documentation

Methods

RandomNumber(min?: number, max?: number): Promise<number>

  • min: number = 0: Minimum value, inclusive
  • max: number = min + 100: Maximum value, inclusive
  • Returns a Promise<number> object.

RandomString(length?: number, charsets?: string | string[]): Promise<string>

  • length: number = 32: The length of the string to generate
  • charsets: string | string[] = ['alpha', 'alpha_upper', 'numeric']: The set of characters to pick from. There are a few built in character sets. You can also pass in an array of charactes to pick from: ['a', 'b', 'c', '1', '2', '3']
  • Returns a Promise<string> object.

Properties

Built in character sets

  • 'alpha': /[a-z]/
  • 'alpha_upper': /[A-Z]/
  • 'numeric': /[0-9]/
  • 'emojis': A selection of easily identifiable emojis, including 😀 👍 🐱 😎 🔥