I want to create a private key and public key, basically a new account in Ethereum using web3. But I want to generate a private key that is 32 bytes in length. Does anyone know how to generate the same?
I used the following code, but not able to generate a 32 bytes long private key.
web3.eth.accounts.create();
Ethereum uses 32 bytes (which is 64 hex characters) long private keys.
You can access the private key generated using the accounts.create()
method (docs) in the privateKey
property.
const account = web3.eth.accounts.create();
console.log(account.privateKey);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With