geth-compatible keystore file can be created in Node using ethereumjs-wallet library:
> var Wallet = require('ethereumjs-wallet');
> var key = Buffer.from('efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378', 'hex');
> var wallet = Wallet.fromPrivateKey(key);
> wallet.toV3String('password');
'{"version":3,"id":"467233bf-45ec-423b-9548-bdc4a42aa099","address":"b14ab53e38da1c172f877dbc6d65e4a1b0474c3c","crypto":{"ciphertext":"17886b7ff355219dd20900543b9592fcd4dc6fe7d8f776f1a4d1c63993112181","cipherparams":{"iv":"434e4e71d2013a2d84e86a6e89efbb0b"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"7a785ab75fa906734788d85ff43a2c8e704af41881dd50a2d52abe08092f07ec","n":262144,"r":8,"p":1},"mac":"98d9a76960dcef22a5fd28a6bf47e5c68a71b30bcf353eccbf5a6555abec78a1"}}'
You can also specify additional options to control kdf, cipher and other wallet params. See here.
About the keystore file and specifications:
It is called: UTC JSON Keystore File
More info: https://theethereum.wiki/w/index.php/Accounts,_Addresses,_Public_And_Private_Keys,_And_Tokens
I found my JSON file:
- I put the HDD to another Linux machine
- installed testdisk, listed my drives (the lost key was at /dev/sdc)
- Then with:
strings /dev/sdc | grep ea52e36ce9481bde98904d4307ba90cbc6cb8ac4
I got a mass amount of data, where I found a JSON like text:
UTC--2017-06-27T23-00-32.157422930Z--ea52e36ce9481bde98904d4307ba90cbc6cb8ac4
followed with the content of key file.
The ea52e36ce9481bde98904d4307ba90cbc6cb8ac4 is my account.
Best Answer
You can use MyEtherWallet or MyCrypto(fork of MyEtherWallet) offline only wallet "view wallet details" function to extract private key from wallet json file. Feel free to use its offline version on an air gapped computer to secure your private key.
Edit: MyCrypto only provides this function in the offline version of the wallet now for obvious security issues of getting a private key from an internet site on a connected computer. So you are warned that you should only do that on an air-gaped computer.