mirror of https://github.com/lukechilds/bip39.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
446 B
19 lines
446 B
11 years ago
|
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))
|
||
|
}
|