crypto-string
v1.0.2
Published
Generate crypto random string that can be used for chat rooms and other id specific use case
Downloads
34
Readme
Random Crypto String Generator
This is a fork from crypto-random-string to work with ExpressJS.
Info
- I wanted a random string for my chat room that should not be ever generated again.
- I tried using the above package but it was either not compliant with ExpressJS or I didn't know how to use it.
- So, I decided to write my own forking the package.
Install
npm i crypto-string
Use
const cryptoString = require('crypto-string')
// Importing the package
let id = cryptoString()
// Generating a random string
console.log(id)
// hfy64j
API
- The package exports a function that returns a random string.
- The function takes an optional parameter
length
that specifies the length of the string.- If the parameter is not specified, the default length is
6
.
- If the parameter is not specified, the default length is
- It generates string from the alphabets and numbers with no special characters (
a-z
,A-Z
,0-9
). - Hope it helps :)