npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

keygen-advance

v1.0.7

Published

Generate highly customisable unique string/hex/url-friendly keys (Suggest any related features thanks)

Downloads

104

Readme

Installation

Install keygen-advance:

npm i keygen-advance

Create a constant:

const keygen = require('keygen-advance');

Source: GitHub

Overview

Keygen-advance includes functions for generating unique random strings, url-friendly keys and hexadecimal keys. Options to add extra characters and disallow specified characters from appearing in generated key (to prevent breaking your code)

Addition filter module to disallow unwanted/inappropriate phrases from appearing in generated key.

Keys

  • gen(length)

Generate random string with specified length

  • gen(length, chars)

Generate random string using only specified characters (array)

  • url(length)

Generate a URL-friendly key

  • hex(length)

Generate random hexadecimal key with specified length

  • SHA256()

Generate SHA256 keys

  • SHA512()

Generate SHA512 keys

Specified Lengths

keygen.short: 11 characters

keygen.medium: 22 characters

keygen.long: 33 characters

keygen.default: Configurable (11 by default) Default Length

If length is not specified, keygen-advance will use keygen.default as length (11 characters by default), this default length is configurable with keygen.setDefault(length)

Examples

const keygen = require('keygen-advance');

// Generate a 32 characters long string
keygen.gen(32) //-> %AAo7O4N1BQd<y80<?A4R§L7c$z$mqY#

// Generate a medium string (22 chars long) only using characters in the charsToUse array
var charsToUse = ['1','0'];
keygen.gen(keygen.medium,charsToUse) //-> 0010110011000100111101

// Generates a short URL-friendly key
keygen.url(keygen.short) //-> m7cBe7vYlFW

// Generate a long hexadecimal key
keygen.hex(keygen.long) //-> 266c76b68dc12e3b4cf1335cd091c9b6c

// Generate a SHA256 key
keygen.SHA256() // 7e0decae06b626bde327951b1099cc8abae4af515383a4c408f7255fdcfece95

// Generate a SHA512 key
keygen.SHA512() //-> A very long and spammy string trust me it works

Options

All options are true by default, and only affect gen() and url()

Note: allowSymbols is false in url()

  • allowUpperCase(boolean)

Allow uppercase characters to appear in key

  • allowLowerCase(boolean)

Allow lowercase characters to appear in key

  • allowSymbols(boolean)

Allow symbols to appear in key

  • allowNumbers(boolean)

Allow numbers to appear in key

Filter

Filter can be used to prevent certain phrases you don't want from appearing in the key, swear words for example.

  • disableFilter(boolean)

Disable filter for gen() and url()

  • setFilter(array)

Overrides the previous filter

Customisations

  • setDefault(length)

Change the default length

  • reset()

Reset everything about this package

Excluded Characters

Some characters like / might just break your code, luckily we got the excluded list characters (works in url() and gen())

  • exclude(char or array)

Prevent character(s) from appearing in the key (add character(s) to the exclude list)

  • allow(char or array)

Allow excluded character(s) to appear in key (remove character(s) from the excluded list)

Extra Characters

Opposite of the excluded characters, add extra possible characters to the key (works in url() and gen())

If same character appear in both lists excluded list has higher priority (cause safety first)

  • add(char or array)

Add extra character to appear in key (add character(s) to the extra list)

  • remove(char or array)

Remove extra character that can appear in key (remove character(s) to the extra list)

Get and Set

Functions to get and set list contents

  • getList()

Returns fullList, aka the final list generated from all the characters and other lists

  • setList(array)

Overrides fullList, recommend not use this because the list get reset by almost every functions, only work in gen()

  • getExcluded()

Returns excluded list

  • setExcluded(array)

Overrides excluded list

  • getExtra()

Returns extra list

  • setExtra(array)

Overrides extra list

Bugs and Suggestions

Pull request or create issue on GitHub please thank you for using