bitcoinjs / bip38

BIP38 is a standard process to encrypt Bitcoin and crypto currency private keys that is less susceptible to brute force attacks thus protecting the user.
http://cryptocoinjs.com/modules/currency/bip38/
MIT License
208 stars 100 forks source link

new Error('Invalid checksum') #30

Closed grio closed 7 years ago

grio commented 7 years ago

Still have a problem. Code is: `var bip38 = require('bip38') var wif = require('wif') var encryptedKey = Buffer.from('6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg', 'hex') var decryptedKey = bip38.decrypt(encryptedKey, 'TestingOneTwoThree', function (status) { //console.log(status.percent) // will print the precent every time current increases by 1000 })

console.log(wif.encode(decryptedKey.privateKey, decryptedKey.compressed)) ` Error is:

`$ node de.js /home/grio/temp/node_modules/bs58check/index.js:46 if (!payload) throw new Error('Invalid checksum') ^

Error: Invalid checksum at Object.decode (/home/grio/temp/node_modules/bs58check/index.js:46:23) at Object.decrypt (/home/grio/temp/node_modules/bip38/index.js:130:31) at Object. (/home/grio/temp/de.js:4:26) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:389:7) `

dcousens commented 7 years ago

6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg is not hex, nor does it need to be put in a Buffer. It is a string. Leave it as a string.

Please follow the Examples :+1: .