New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@kompanie/random-string

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kompanie/random-string

Generates a random string in the desired length. It also supports seeds and specifiying which letters should be used. This function is not cryptographically secure.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

random-string

Generates a random string in the desired length. It also supports seeds and specifiying which letters should be used. This function is not cryptographically secure.

Usage

At first you need to install the package using the following command:

npm i @kompanie/random-string

The generate function has three parameters:

  • length specifies how long the generated string should be.
  • seed is a number, which allows to generate the same string again. Optional.
  • allowedCharacters is a string, which specifies all the characters that are allowed in the string. Optional.
// Generate a string containing 5 characters
const result = RandomString.generate(5);

// Generate a string containing 6 characters, using the seed 5
const result = RandomString.generate(6, 5);

// Generate a string containing 7 characters, using the seed 4, using only these characters
const result = RandomString.generate(7, 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

// Generate a string containing 7 characters, using no seed, using only these characters
const result = RandomString.generate(7, null, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

FAQs

Package last updated on 12 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts