What is rndm?
The 'rndm' npm package is a simple utility for generating random strings. It is useful for creating unique identifiers, tokens, or any other scenario where a random string is needed.
What are rndm's main functionalities?
Generate Random String
This feature allows you to generate a random string of default length. The generated string can be used for various purposes such as unique identifiers or tokens.
const rndm = require('rndm');
const randomString = rndm();
console.log(randomString);
Generate Random String with Custom Length
This feature allows you to generate a random string of a specified length. In this example, a random string of 16 characters is generated.
const rndm = require('rndm');
const randomString = rndm(16);
console.log(randomString);
Other packages similar to rndm
uuid
The 'uuid' package is used to generate RFC4122 UUIDs (Universally Unique Identifiers). Unlike 'rndm', which generates random strings, 'uuid' generates standardized UUIDs which are often used in databases and distributed systems.
nanoid
The 'nanoid' package is a tiny, secure, URL-friendly, unique string ID generator. It is similar to 'rndm' in that it generates random strings, but 'nanoid' focuses on security and URL-friendliness, making it suitable for use in web applications.
shortid
The 'shortid' package is used to generate short, non-sequential, URL-friendly unique IDs. It is similar to 'rndm' but provides shorter and more URL-friendly IDs, which can be useful for creating human-readable URLs.
RNDM
Random string generator.
Basically Math.random().toString(36).slice(2)
,
but with both upper and lower case letters and arbitrary lengths.
Useful for creating fast, not cryptographically secure salts.
API
var rndm = require('rndm')
var salt = rndm(16)
var salt = rndm(length)
var salt = rndm.base62(length)
var salt = rndm.base36(length)
var salt = rndm.base10(length)
var random = rndm.create(characters)
Create a new random generator with custom characters.