Skip to content

mistersimon/wordhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordHash

WordHash creates a human-readable hash designed for uuids but can handle other strings too.

Installation

Use the package manager npm to install wordhash.

npm install wordhash

Usage

var WordHash = require('wordhash');

var wordHash = WordHash();

const input = "0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd";

wordHash.hash(input);
//  "video-sad-carolina-twenty"

wordHash.hash("d13175d4-bee9-4e80-b24c-89c15c126cbf");
//  "massachusetts-social-apart-robert"
  
WordHash({ salt: 'saltySalt'}).hash(input)
//  "skylark-bakerloo-low-early"

WordHash({ length: '3'}).hash(input)
//  "video-sad-carolina"

WordHash({ separator: '~'}).hash(input)
//  "video~sad~carolina~twenty"

WordHash({ separator: null }).hash(input)
//  ["video", "sad", "carolina", "twenty"]

See test.js for usage more examples

Caveats

WordHash conversions are one way, and are not as 'unique' as uuids meaning its more likely to be collisions. With default settings its statistical uniqueness is only around 1 in 4.3 billion.

How It Works

Each word is generated by mapping a segment of the input to a word in the wordlist. Segments are taken from the start of the md5 hash of the string and salt.

This algorithm is deterministic, so the same input and wordlist will always produce the same output.

Inspiration

  • humanhash: Great library and wordset but does not support salting and wordlist is fixed to 256 words
  • hashwords: Good implimentation of salting and variable length wordlist

License

Unlicense

About

Hash into human friend words

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published