Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including random-keygen with all npm packages installed. Try it out:

var randomKeygen = require("random-keygen")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

random-keygen v1.0.4

Simple random keygen.

Random Keygen Build Status

Random-Keygen NPM

Simple random key and unique keys.

Install

  npm install random-keygen --save

Or

  yarn add random-keygen

Usage

get([options])

Random one key with the given options. Returns a string.

var randkey = require('random-keygen');

var key = randkey.get({
    length: 10,
    numbers: true
});

console.log(key);

getMulti(amount[, options])

Bulk create multiple keys at once, with the same options for all. Returns an array.

var randkey = require('random-keygen');

var keys = randkey.getMulti(3, {
    length: 10,
    uppercase: false
});

console.log(keys);

Options

Any of these can be passed into the options object for each function.

NameDescriptionDefault Value
lengthInteger, length of key.10
numbersBoolean, put numbers in key.false
symbolsBoolean, put symbols in key.false
uppercaseBoolean, use uppercase letters in key.true
excludeSimilarCharactersBoolean, exclude similar chars, like 'i' and 'l'.false
excludeString, characters to be excluded from key.''
strictBoolean, key must include at least one character from each pool.false

TopDev - Việc làm IT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free