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

v0.4.0

Published

url-friendly, random, unique key/token generation

Downloads

748

Readme

Keygen

A set of functions for url-friendly, random, unique key/token generation

Getting Started

Install Keygen:

npm install keygen --save

Overview

Keygen can be used to generate url-friendly or hexadecimal keys. The url-friendly variety should be favored where possible since they can represent a significantly larger keyspace with shorter keys.

Examples

URL Friendly Keys:

var keygen = require('keygen');

// generate a small url-friendly key
keygen.url(keygen.small);  //-> 'u3WZbDyN57J'

// generate a medium url-friendly key
keygen.url(keygen.medium);  //-> '5yQZwZsLCaW9W3kmKxx7Ac'

// generate a default-sized (medium) key
keygen.url();  //-> '4wUtvcP5izgTRwV7GPZp9f'

// generate a large url-friendly key
keygen.url(keygen.large);  //-> 'zj6BYUikZeDFwrj8yn9xRdFVXQbKPTQWDs8fqq9fRkqj'

// generate a huge url-friendly key via a custom length
keygen.url(89);  //-> '7BrhcHQb47GUeJBXA5kksScVbihrQikB4Nf9KX8sA8xRmkhf7ysrtUvhFPa9cNhvdyKiLpjC5jq2b73tTJSEPnXm7'

Hexadecimal Keys:

var keygen = require('keygen');

// generate a small hex key
keygen.hex(keygen.small);  //-> 'e9732d18888'

// generate a medium hex key
keygen.hex(keygen.medium);  //-> '910886cd435e93eef7e22e'
// or
keygen.hex();  //-> '8f07d173de8786d5488e3e'

// generate a large hex key
keygen.hex(keygen.large);  //-> '9c90543d255fe6f71a593f807034b5e123f26081ca73'

// generate a huge hex key via a custom length
keygen.hex(179);  //-> '39e122ca2b33ba9471d36463d1a01664ad654c77f82da653dca42590ecbf61794ebe25ac6952bfb325caa2c50bd59bd842922be8976035fbcdc8ac1afcee6d02a979e809e459a653167c7fef452b3e16b8f05b9d23edb895680'

Asynchronous Key Generation:

Cryptographically random key generation may result in minimal blocking for sufficient entropy. For this reason, all the synchronous examples listed above have asynchronous counterparts.

var keygen = require('keygen');

// generate a medium url-friendly key asynchronously
keygen.url(keygen.medium, function(key) {
  console.log(key);  //-> '5yQZwZsLCaW9W3kmKxx7Ac'
}); //-> undefined

// generate a default-sized (medium) hexadecimal key asynchronously
keygen.hex(function(key) {
  console.log(key);  //-> '8f07d173de8786d5488e3e'
}); //-> undefined

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

Release History

(Nothing yet)