Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dudeofawesome/secure-random-value
Generates cryptographically secure random values
https://github.com/dudeofawesome/secure-random-value
List: secure-random-value
Last synced: about 8 hours ago
JSON representation
Generates cryptographically secure random values
- Host: GitHub
- URL: https://github.com/dudeofawesome/secure-random-value
- Owner: dudeofawesome
- License: mit
- Created: 2017-03-29T00:02:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T21:58:15.000Z (over 2 years ago)
- Last Synced: 2024-11-01T06:46:50.757Z (18 days ago)
- Language: TypeScript
- Size: 267 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# secure-random-value [![Travis CI Status](https://travis-ci.org/dudeofawesome/secure-random-value.svg?branch=master)](https://travis-ci.org/dudeofawesome/secure-random-value) [![NPM version](https://badge.fury.io/js/secure-random-value.svg)](https://www.npmjs.com/package/secure-random-value) [![codecov](https://codecov.io/gh/dudeofawesome/secure-random-value/branch/master/graph/badge.svg)](https://codecov.io/gh/dudeofawesome/secure-random-value)
Generates cryptographically secure random values
## Using Secure Random Value
#### 1. Install as a dependency
```shell
yarn add secure-random-value
```
#### 2. Import package
```TypeScript
import { RandomString } from 'secure-random-string';
```
#### 3. Get a random value
```TypeScript
let random_string = await RandomString();
```## Documentation
### Methods
#### `RandomNumber(min?: number, max?: number): Promise`
- `min: number = 0`: Minimum value, inclusive
- `max: number = min + 100`: Maximum value, inclusive
- Returns a `Promise` object.#### `RandomString(length?: number, charsets?: string | string[]): Promise`
- `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](#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` object.### Properties
#### Built in character sets
- `'alpha'`: `/[a-z]/`
- `'alpha_upper'`: `/[A-Z]/`
- `'numeric'`: `/[0-9]/`
- `'emojis'`: A selection of easily identifiable emojis, including 😀 👍 🐱 😎 🔥