ethereumjs / keythereum

Create, import and export Ethereum keys
MIT License
609 stars 163 forks source link

import key from string #10

Closed louisabraham closed 7 years ago

louisabraham commented 7 years ago

Is it possible to import a keystore file from a string ? For example, I would like to be able to drop my keystore file in the browser to use it, but I haven't seen a function to read the account from a string.

tinybike commented 7 years ago

The keystore files are in JSON format, so they can be parsed in JavaScript simply by using the built-in JSON.parse method. Here's an example using HTML5 FileReader: https://github.com/AugurProject/augur/blob/stable/app/components/Register.jsx#L250-L267

louisabraham commented 7 years ago

Oh sorry, I had only seen importFromFile, so I suppose the keyObject in keythereum.recover(password, keyObject) is simply the parsed JSON ?

tinybike commented 7 years ago

Yes, that's correct.

louisabraham commented 7 years ago

Thank you very much!