mirror of
https://github.com/status-im/bip39.git
synced 2025-01-25 03:49:03 +00:00
19 lines
446 B
JavaScript
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))
|
|
}
|