Simple random key and unique keys.
npm install random-keygen --save
Or
yarn add random-keygen
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);
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);
Any of these can be passed into the options object for each function.
Name | Description | Default Value |
---|---|---|
length | Integer, length of key. | 10 |
numbers | Boolean, put numbers in key. | false |
symbols | Boolean, put symbols in key. | false |
uppercase | Boolean, use uppercase letters in key. | true |
excludeSimilarCharacters | Boolean, exclude similar chars, like 'i' and 'l'. | false |
exclude | String, characters to be excluded from key. | '' |
strict | Boolean, key must include at least one character from each pool. | false |