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

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