-
-
Save johansten/35f4767e2f1d4d108a4bb21ff8289ec7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
download all of the files into the same folder | |
change the contents of main.js: | |
replace the encrypted seed with yours | |
replace the password | |
run | |
> npm install | |
and then | |
> node main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sjcl = require('sjcl'); | |
const encryptSeed = (seed, key, cipherName, modeName) => { | |
const cipher = new sjcl.cipher[cipherName](key); | |
const rawIV = sjcl.random.randomWords(3); | |
const encryptedData = sjcl.mode[modeName].encrypt( | |
cipher, | |
sjcl.codec.utf8String.toBits(seed), | |
rawIV | |
); | |
return [ | |
sjcl.codec.base64.fromBits(rawIV), | |
sjcl.codec.base64.fromBits(encryptedData) | |
]; | |
}; | |
const encrypt = (seed, password) => { | |
const saltBits = sjcl.random.randomWords(4); // 128 bits of salt, was 256 bits | |
const numRounds = 4096; | |
const key = sjcl.misc.pbkdf2(password, saltBits, numRounds); | |
const salt = sjcl.codec.base64.fromBits(saltBits); | |
const cipherName = 'aes'; | |
const modeName = 'gcm'; | |
const blob = encryptSeed(seed, key, cipherName, modeName); | |
return ['1', salt, blob]; | |
}; | |
const decryptSeed = (blob, key) => { | |
const cipherName = 'aes'; | |
const modeName = 'gcm'; | |
const cipher = new sjcl.cipher[cipherName](key); | |
const rawIV = sjcl.codec.base64.toBits(blob[0]); | |
const rawCipherText = sjcl.codec.base64.toBits(blob[1]); | |
const decryptedData = sjcl.mode[modeName].decrypt( | |
cipher, | |
rawCipherText, | |
rawIV | |
); | |
return sjcl.codec.utf8String.fromBits(decryptedData); | |
}; | |
const decrypt = (data, password) => { | |
const saltBits = sjcl.codec.base64.toBits(data[1]); | |
const numRounds = 4096; | |
const key = sjcl.misc.pbkdf2(password, saltBits, numRounds); | |
return decryptSeed(data[2], key); | |
}; | |
module.exports = { | |
encrypt: encrypt, | |
decrypt: decrypt | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('./crypto.js'); | |
const encryptedSeed = ["1","ZCtl/+vWiLL358Jz+xnP5A==",["GgmFU37DSX4evSMU","CoMGXWHqDmLwxRAgORqjK/MyFEMAkMbqvDEDMjn4veVwpHab9m6Egcwp70qEJsRhjkHjCMWj9zX40tu9UK5QACuB8gD1r9Cu"]]; | |
const password = 'lacoin'; | |
const decryptedSeed = crypto.decrypt(encryptedSeed, password); | |
console.log(decryptedSeed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "lacoin", | |
"version": "1.0.0", | |
"description": "", | |
"main": "crypto.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"sjcl": "^1.0.7" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok with the help of some people on the stellar sub on reddit (https://www.reddit.com/r/Stellar/comments/ltcbb5/gaining_access_to_stellar_wallet_created_on/) I was able to figure out how to do this on a Mac. I have written the step by step instructions so a complete novice could do it:
"key":["1","Dt/bcdLAx8TnEd4qF/7+sQ==",["jwFqX+meUt3ioxnG","6woh7nRS1CcEN6qiWEI+knY9VyYdMzqlGxpxX6ZfPfAPVg9wOTYevryOmyGC3ycQ2asgPYx1pIW4Fp9Jj4pDGkKGWuhoZKsW"]]
JUST COPY ONLY THE CHARACTERS FROM ["jwFqX to the ending ]] (this is your encrypted key)
["GgmFU37DSX4evSMU","CoMGXWHqDmLwxRAgORqjK/MyFEMAkMbqvDEDMjn4veVwpHab9m6Egcwp70qEJsRhjkHjCMWj9zX40tu9UK5QACuB8gD1r9Cu"]]