From d026bbe2ef30c9b936aa0888677abb912694defc Mon Sep 17 00:00:00 2001 From: Wei Lu Date: Mon, 31 Mar 2014 14:07:34 +0800 Subject: [PATCH] add generateMnemonic --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 0e9fdc5..8a2c874 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,12 @@ BIP39.prototype.entropyToMnemonic = function(entropy){ }, this).join(' ') } +BIP39.prototype.generateMnemonic = function(strength){ + var strength = strength || 128 + var entropy = crypto.randomBytes(strength/8).toString('hex') + return this.entropyToMnemonic(entropy) +} + function salt(password) { return encode_utf8('mnemonic' + (password || '')) }