add generateMnemonic

This commit is contained in:
Wei Lu 2014-03-31 14:07:34 +08:00
parent 7b78cc5350
commit d026bbe2ef
1 changed files with 6 additions and 0 deletions

View File

@ -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 || ''))
}