@basementscripts/token-generator
v1.0.2
Published
Node.js token generator
Keywords
Readme
@basementscripts/token-generator
Generate random char string of alpha, numeric, and special characters.
Getting Started
$ yarn add @basementscripts/token-generatorOptions
type - Character type of the token string available options are;
Alpha- alpha upper and lower chars onlyabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZAlphaLower- alpha lower chars onlyabcdefghijklmnopqrstuvwxyzNumeric- numeric chars only0123456789Special- special chars only!@#$%^&*()-_=+[{]}<>AlphaNumeric- alpha and numeric chars only0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZAlphaNumericLower- alpha and numeric chars lowercase only0123456789abcdefghijklmnopqrstuvwxyzFull- includes all available chars as potential0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_=+[{]}<>
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 })
