A simple diceware module
family-friendly-diceware
generates easily sharable ids using the the EFF's family friendly diceware list.
This package intended for creation of easy to distribute UUID's, so we provide some backwards functionality (phrase to integer index).
As this is meant to be use with user input, attempts to normalize and correct obvious errors are made. For example, phrase_to_id
begins
with a simple case and spacing normalization, then proceeds to call upon an optional fixer
function (implemented for example via levenshein distance) to correct for more complex errors.
npm install family-friendly-diceware
diceware = ; diceware> phrase: 'turtle astride porous' id: '286370444755' diceware> 'turtle astride porous' diceware> 'turtle astride porous' diceware;> 'turtle astride porous'
Example fixer (assume words
is a table containing all words of a give diceware wordlist):
(input_str text) RETURNS text AS$$SELECT * FROM words WHERE levenshtein(input_str, word) < 3 ORDER BY levenshtein(input_str, word) LIMIT 1;$$ LANGUAGE SQL;