Implementation of https://raw.github.com/spesmilo/electrum/master/lib/mnemonic.py in JavaScript