Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pleonasm with all npm packages installed. Try it out:

var pleonasm = require("pleonasm")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pleonasm v1.0.0

Create English phrases from hex numbers

pleonasm

Create English phrases from hex strings that are easier to recognize and remember

Javascript API

.onload(fn)

Register a function to be called when the when the dictionaries are loaded and pleonasm is ready to use.


.encode('601a9f')

Encode a hex string into an English phrase. Returns an object, with the key 'code' as the result:

{ translation: 'vulngf',
  codeWords: [ 'visualizing', 'free' ],
  code: 'visualizing free',
  spaced: 'v  u l   ng f   ' }

Can take wordDelimiter and groupDelimiter as additional arguments (see .format).

.encode('0167aa36cf832', '_', '/')
{ translation: 'ulvtnnmvcfwmk',
  codeWords: 
   [ 'rule',  'veterinarian',
     'move',  'care',
     'fewer', 'mark' ],
  code: 'rule_veterinarian_move/care_fewer_mark',
  spaced: ' ul  v t   n    n m v  c    f w   m  k' }

.decode('visualizing free')

Decode an English phrase to get a hex number.

{ hex: '601a9f',
  spaced: 'v  u l   ng f   ',
  translation: 'vulngf' }

.format(codeWords, wordDelimiter, groupDelimiter)

Format an array of code words into a string. Words are connected with wordDelimiter (usually ' '), phrases of three words each are connected with groupDelimiter (usually ', ')).

Javascript (Browser)

Files needed:

dictionaries/
-- adj.txt
-- noun.txt
-- verb.txt
js/
-- pleonasm.js
<script src="js/pleonasm.js"></script>
<script>
  pleonasm.onload(function() {
    var encoded = pleonasm.encode('ad3a507').code;
  });
</script>

node.js

Install via npm:

npm install pleonasm

npm test pleonasm

Usage:

var pleonasm = require('pleonasm');

pleonasm.onload(function() {
  var encoded = pleonasm.encode('ad3a507').code;
});

Python

from pleonasm import Encoder, decode

enc = Encoder('../dictionaries')
encoded = enc.encode('601a9f')
print encoded # 'visualizing free'

decoded = decode('rule_veterinarian_move')
print decoded # '0167aa36'

Acknowledgements and other projects

The dictionaries are created from the 1-grams of the Google Ngram data.

The idea of the grammatical template stems from tripphrase.

humanhash creates hashes (compressed) from a 256-word dictionary.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free