random-number-string

1.0.1 • Public • Published

Random-Number-String

A simple helper library to provide cryptographically secure random numbers and strings. Why? Because I couldn't find a package for both.

Installing:

npm install random-number-string

Using:

const { charSet, randFlt, randInt, randStr } = require('random-number-string');
 
console.log(charSet);
console.log(randFlt());
console.log(randInt());
console.log(randStr());

charSet

Includes some commonly used character sets like the alpha-numerics. Use it like this:

//These ones are properties:
console.log(charSet.LowerCase);
console.log(charSet.UpperCase);
console.log(charSet.Numeric);
console.log(charSet.PlusSlash);
console.log(charSet.Symbols);
console.log(charSet.Symbols2);
console.log(charSet.Brackets);
console.log(charSet.Quotes);
 
//These ones are methods that return the sets as strings:
console.log(charSet.Alpha());
console.log(charSet.AlphaNumeric());
console.log(charSet.AlphaNumericSymbol());
console.log(charSet.Base64());
console.log(charSet.Restricted());

randFlt(min, max, res)

Returns a random float in the range [min, max).

Default range is [0, 1). res is set for you.

randInt(min, max, res)

Returns a random integer in the range [min, max).

Default range is [0, 100). res is set for you.

randStr(len, chars)

Returns a random string of length len from a character set chars.

Default returns an alpha-numeric string of length 8.

Package Sidebar

Install

npm i random-number-string

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

5.48 kB

Total Files

4

Last publish

Collaborators

  • dobberoonski