bip39/index.js
2014-03-10 10:49:53 +08:00

19 lines
446 B
JavaScript

Crypto = require('crypto-js')
module.exports = {
mnemonicToSeed: mnemonicToSeed
}
function mnemonicToSeed(mnemonic, password){
var options = {iterations: 2048, hasher: Crypto.algo.SHA512, keySize: 512/32}
return Crypto.PBKDF2(mnemonic, salt(password), options).toString(Crypto.enc.Hex)
}
function salt(password) {
return encode_utf8('mnemonic' + (password || ''))
}
function encode_utf8(s){
return unescape(encodeURIComponent(s))
}