Module: token-generator

Unique token generator.
Version:
  • 1.0
Author:
  • Luka Kralj

Methods


<inner> addLetters(token)

Inserts letters into the token so that it is even harder to guess.
Parameters:
Name Type Description
token string Token obtained from the timestamp.
Returns:
Token with added letters.
Type
string

<inner> generateLoginToken()

Generates a unique sequence of numbers and letters that can be used for identification. This generates a longer token than generateToken() which makes it more secure.
Returns:
A unique token.

<inner> generateToken()

Generates a unique sequence of numbers and letters that can be used for identification.
Returns:
A unique sequence of numbers and letters (usually around 40 characters long).
Type
string

<inner> randInt(min, max)

Generates a random integer.
Parameters:
Name Type Description
min number Lower bound.
max number Upper bound.
Returns:
Random integer.
Type
number

<inner> randLetter()

Returns a random letter from A-Z or a-z.
Returns:
A random letter.

<inner> randSeq(max)

Generates a random sequence of letters, possibly empty.
Parameters:
Name Type Default Description
max number 3 Maximum length of the string that we want.
Returns:
Random sequence, possibly empty.
Type
string