simple-randstring
v1.1.9
Published
Create a random string fast
Downloads
16
Readme
simple-randstring
Create random strings fast
Usage:
import { randomString } from 'simple-randstring'
// Use Math.random() to create random strings, fast but not secure
// Default charset is [0-9a-zA-Z]
randomString(30)
// Use window.crypto( on the browser ) or crypto( on node ) to create random strings
// The speed is only half compare to Math.random() but it is more secure
// If window.crypto is not supported , it will fall back to use Math.random()
randomString(30, true)
import { randomString, setRandCharset } from 'simple-randstring'
// Define your own charset
setRandCharset('abcdefg()!@#$%')
// Return something like ')ag)(#fbe@!a%g%$g(b#'
randomString(20, true)