random-token
generate a (pseudo-)random string of given length composed from alphanumeric characters
install
npm install random-token
usage
initiate
var randomToken = ;
default salt is "abcdefghijklmnopqrstuvwxzy0123456789"
var token = ; // example output → 'xg8250nbg4klq5b3'
different salt
var randomToken = ;var token = ; // example output → '3ZGErMDCwxTOZYFp'
Note: valid salts are strings with length > 0
if an invalid salt is given to .create
, the returned generator will use the default salt
convenience methods
.create
create a different generator
var randomToken = ;var rt = randomToken;var token = ; // example output → 'A0aAAaA0AA0Aa0AA'
.salt
you can check a generators salt by calling .salt()
on it
var randomToken = ;randomToken; // output → 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'