@basementscripts/token-generator
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@basementscripts/token-generator

Coverage

Generate random char string of alpha, numeric, and special characters.

Getting Started

$ yarn add @basementscripts/token-generator

Options

type - Character type of the token string available options are;

  • Alpha - alpha upper and lower chars only abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  • AlphaLower - alpha lower chars only abcdefghijklmnopqrstuvwxyz
  • Numeric - numeric chars only 0123456789
  • Special - special chars only !@#$%^&*()-_=+[{]}<>
  • AlphaNumeric - alpha and numeric chars only 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  • AlphaNumericLower - alpha and numeric chars lowercase only 0123456789abcdefghijklmnopqrstuvwxyz
  • Full - includes all available chars as potential 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_=+[{]}<>

length - The total length of the string desired

leadWithAlpha - Force string to start with a leading alpha char

Basic Use

The default generated token will be a 32 char alphanumeric token string eg. FjFoaNmxGAZFP4FaMoPG1K2vYuw3bGFG

import { generateToken } from '@basementscripts/token-generator'

...

const token = generateToken()

Generate 6 Digit Token

Generates a 6 digit token string eg. 085293

import { generateToken, Chars } from '@basementscripts/token-generator'

...

const token = generateToken({ type: Chars.Numeric, length: 6 })

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i @basementscripts/token-generator

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.55 kB

    Total Files

    12

    Last publish

    Collaborators

    • justinandersonca
    • basementscripts-devops