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

node-humanhash

v1.0.3

Published

A proof of concept to create more user-friendly hash digests that are based on human language rather than indecipherable base16 strings

Downloads

9

Readme

Node.js Human Readable Hashes

This Node.js package exposes an interface for 2-way conversion between base-n encoded hash digests and human-readable strings.

Installation

npm install node-humanhash

Example (see example.js)

var rhd = require('node-humanhash');

// this digest is base16, created with SHA3.
var digest = "c135d447e3aa2d07f574d608b9cedfee2c3cc5f7a264b8b8bda86fc05ede4139";

console.log(digest);
var humanizedDigest = rhd.humanizeDigest(digest);
console.log(humanizedDigest);
console.log(rhd.dehumanizeDigest(humanizedDigest));

The result is

c135d447e3aa2d07f574d608b9cedfee2c3cc5f7a264b8b8bda86fc05ede4139

farther do white window gone are insidious when across face lamplight the life begin or leaning argument visit eyes silent rich once measured measured voices arms slides music leap lie michelangelo it

c135d447e3aa2d07f574d608b9cedfee2c3cc5f7a264b8b8bda86fc05ede4139

We can therefore convert between a boring old base16 encoded hash that's more or less unreadable to something a little nicer on human eyes.

Usage

humanizeDigest(digest, base)

digest is the string to "humanize", and base is the base (only 2 <= base <= 32 are currently supported) of the encoding used to create the digest (defaults to 16). Returns a more human readable string representation of the digest.

dehumanizeDigest(humanizedDigest, base)

humanizedDigest is a previously created humanized digest string, and base is the base (only 2 <= base <= 32) are currently supported) of the encoding used to create the original digest. Returns the original digest used to create the humanized digest string.

Technical Details

We use a specimen text (in the default implementation, T.S. Eliot's The Lovesong of J. Alfred Prufrock) to deterministically generate an array of unique words used in the text in order of appearance. The word-list-maker.js utility converts a textfile of the specimen text to a .json file that can then be used in the place of prufrock.txt.json in index.js (fork for Shakespeare!)

The meat of the conversion process chunks the input digest string, and then uses those chunks as indexes into the word array. Because the word array is deterministically generated and encoding is also deterministic, we can hash in two directions with no fear of collision (something occasionally missing from other human readable hash implementations).