Creating Ethereum private key from a string

private-key

I have a simple string, for example test – and I need to convert it to Ethereum private key 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

What is an algorithm? Which functions should I apply? I want to make it with nodejs.

Best Answer

You can do it like this using Web3 libraries for programming language:

web3.sha3("my super secret passphrase with a lot of entropy")

You can do it like this on a UNIX/Linux command prompt:

# Needs to have openssl command lines tools installed
printf "supser secret passphra5e" | openssl dgst -sha256
3c37fb6a9605750240461a90d43ca6742b468479a5ec8380113f6be0bb29168b

The only requirement of a private key is that it is 256 bit integer number, or 32 bytes or random data (with some small limitations)

Note that most simple passphares that are guessable are guessed. For example, any sentence from the bible or other famous book is no go.

Check web3.js for JavaScript and web3.py for Python.