<pre><code>com.google.bitcoin.core.ECKey key = new com.google.bitcoin.core.ECKey(); // keypair
byte[] pub = key.getPublicKey(); // byte array

String prv; 
prv = key.getPrivateKeyEncoded(com.google.bitcoin.core.NetworkParameters.prodNet());
</code></pre>

CC BY-SA 3.0
2013-10-10T21:56:59.273Z
2013-10-10T21:56:59.273Z
Jus12
<p>How can I create a base58 private key and public key in Java? I'm pretty familiar with Java and I have the bitcoinj-minimal code, but it's not clear to me how I can generate a base58 key pair from the code.</p>

<private-key><public-key><bitcoinj><java><base58>
Creating Base58 public key & private key in Java?
simmi
# Creating Base58 public key & private key in Java?

(Asked by: username_0 on 2013-07-11)

How can I create a base58 private key and public key in Java? I'm pretty familiar with Java and I have the bitcoinj-minimal code, but it's not clear to me how I can generate a base58 key pair from the code.

**Tags:** private-key, public-key, bitcoinj, java, base58


---

## 1 answers

### Answer by username_1 on 2013-10-10. Score: 2

```
com.google.bitcoin.core.ECKey key = new com.google.bitcoin.core.ECKey(); // keypair
byte[] pub = key.getPublicKey(); // byte array

String prv; 
prv = key.getPrivateKeyEncoded(com.google.bitcoin.core.NetworkParameters.prodNet());

```


---

