Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

r4ndm-str

ericoalmeida949MIT1.2.0TypeScript support: included

Generate random strings

password, random string, strong password, random key

readme

R4ndm-Str

GitHub package.json version npm NPM GitHub Workflow Status GitHub top language GitHub issues

Description

Library to provide a way to generate random strings using or not capital letters, small letters, numbers and symbols. It is also possible to remove the similar characters

  • Capital letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  • Small letters: abcdefghijklmnopqrstuvwxyz
  • Numbers: 0123456789
  • Symbols: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
  • Similar characters: 0126GIOSZgiosz`'

How to use

Install

  • Install with npm
npm i r4ndm-str
  • or with yarn
yarn add r4ndm-str

Example

  • See the code bellow for generate a password
const { RandomStringGenerator } = require('r4ndm-str')

const randomString = new RandomStringGenerator()

const size = 10

const password = randomString.generate(size)
console.info(password)
//printed console: QF:Qr\W(;M

Settings

It is possible to pass some parameters to indicate what kind of characters will be used to generate a random string. Let's see!

  • useCapitalLetters: Indicates if use capital letters
  • useSmallLetters: Indicates if use small letters
  • useNumbers: Indicates if use numbers
  • useSymbols: Indicates if use Symbols
  • removeSimilarCharacters: To avoid issues with similar characters, it's possible to remove them.

Examples

  • See the code bellow for generate a password
const { RandomStringGenerator } = require('r4ndm-str')

const randomString = new RandomStringGenerator({
  useSmallLetters: false,
  useSymbols: false,
  removeSimilarCharacters: true
})

const size = 10

const password = randomString.generate(size)

console.info(password)
//printed console: 5H94BFQXE3