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

sspg

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sspg

The Simplest Strong Password Generator

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

spg.js

JavaScript library of the Simplest Strong Password Generator

Usage

import {gen} from "spg";

gen("0aA", 10);

Available functions:

  • gen(config, length): Generate a password with the length of length
  • gens(config, length): same as gen, but using a cryptographically safe random generator
  • create(safe:boolean): create an instance of Spg

Configuration

The gen and gens functions' first parameter can be an SpgGenerationConfig or a string.

Whether to use the safe or unsafe random generator can be specified within the configuration can override the Spg.safe property. (and gen or gens)

SpgGenerationConfig

type SpgGenerationConfig={
  characters: string; // The characters from which the password will be generated
  safe?: boolean;     // Whether to use a cryprographically safe random generator
}

The Spg format

The Spg adopts a straightforward approach for the generation, which was come up with by @RLt.

Configuration strings are made up of characters, which is parsed separately. The results are eventually added up to form a collection of characters from which the password will be generated.

for example, 0aA becomes [0-9a-zA-Z].

Available characters:

0      -> [0-9]
a      -> [a-z]
A      -> [A-Z]
- or _ -> -_
.      -> !@#$%^&*,.;:/?+=
[ or ] -> ()[]{}<>|'"`~

Specially, there are several special characters.

c -- escape, characters after this are directly put into the output collection
s -- use the safe random generator
u -- use the unsafe random generator

Keywords

random

FAQs

Package last updated on 23 Feb 2025

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