<p>Not Java, but interesting to examine as a reference to explore Java functionality with this fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc  being a secp256k1 elliptic curve private key.</p>

<ol>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx sha256 | bx ripemd160 | bx wrap-encode -v 0 | bx base58-encode</code>
<strong>1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx sha256 | bx ripemd160 | bx base58check-encode -v 0</code>
<strong>1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160 | bx base58check-encode -v 0</code>
<strong>1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160 | bx address-encode -v 0</code>
<strong>1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public | bx bitcoin160 | bx address-encode -v 0</code>
<strong>1FbGdbUU1ibBtanPTLAuMTAJ4Y9HkatkcX</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public</code>
<strong>02cf90dc2b34937fff7cf1eb4b260f1e5610231134b864761e508505938bbef8fc</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u</code>
<strong>04cf90dc2b34937fff7cf1eb4b260f1e5610231134b864761e508505938bbef8fc00aeb265797336b74146e018da7b78070f1f1072540a2c3fe83637ca5d605b3c</strong></li>
<li><code>% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160</code>
<strong>c991f856a2992c877d3923298e67b88fe61e6c76</strong></li>
</ol>

CC BY-SA 3.0
2016-01-02T01:56:07.513Z
2016-01-02T07:09:09.200Z
2016-01-02T07:09:09.200Z
skaht
<p>Yes.</p>

<pre><code>ECKey key = ...;
String addr = key.toAddress(MainNetParams.get()).toString();
</code></pre>

<p><a href="https://bitcoinj.github.io/javadoc/0.12/org/bitcoinj/core/ECKey.html#toAddress-org.bitcoinj.core.NetworkParameters-" rel="noreferrer">https://bitcoinj.github.io/javadoc/0.12/org/bitcoinj/core/ECKey.html#toAddress-org.bitcoinj.core.NetworkParameters-</a></p>

CC BY-SA 3.0
2016-01-02T09:23:57.917Z
thanks for your answer.The key.toAddress() function was the one that i was looking for.
gtopal
CC BY-SA 3.0
2015-12-31T18:32:30.983Z
2015-12-31T18:32:30.983Z
Nick ODell
<p>I am trying to convert my Bitcoin Address with BitcoinJ in order to look like a normal address such as this:
1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy.</p>

<p>I haven't found anything exept for the <code>Base58.encode()</code> which takes the <code>getPubkeyHash()</code> of my <code>ECKey</code> and returns something like this:
5ahorsFsHTcG3f662evowc5c9zf.</p>

<p>Which means that encodes the given bytes in base58,no checksum is appended according to the API.But i want my address to look like the above one.</p>

<p>Is there any algorithm in java  for <strong>encoding address_byte_string (consisting of 1-byte_version + hash_or_other_data + 4-byte_check_code)</strong>?</p>

<p>according to this:<a href="https://en.bitcoin.it/wiki/Base58Check_encoding" rel="nofollow">https://en.bitcoin.it/wiki/Base58Check_encoding</a></p>

<address><bitcoinj><base58>
Encoding my Bitcoin Address with Base58 encoding
gtopal
# Encoding my Bitcoin Address with Base58 encoding

(Asked by: username_0 on 2015-12-31)

I am trying to convert my Bitcoin Address with BitcoinJ in order to look like a normal address such as this:
1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy.

I haven't found anything exept for the `Base58.encode()` which takes the `getPubkeyHash()` of my `ECKey` and returns something like this:
5ahorsFsHTcG3f662evowc5c9zf.

Which means that encodes the given bytes in base58,no checksum is appended according to the API.But i want my address to look like the above one.

Is there any algorithm in java for **encoding address\_byte\_string (consisting of 1-byte\_version + hash\_or\_other\_data + 4-byte\_check\_code)**?

according to this:<https://en.bitcoin.it/wiki/Base58Check_encoding>

**Tags:** address, bitcoinj, base58


---

## 2 answers

### Answer by username_2 on 2015-12-31. Score: 5 | Accepted answer

Yes.
ECKey key = ...;
String addr = key.toAddress(MainNetParams.get()).toString();

https://bitcoinj.github.io/javadoc/0.12/org/bitcoinj/core/ECKey.html#toAddress-org.bitcoinj.core.NetworkParameters-

> **Comments:**
> **username_0**: thanks for your answer.The key.toAddress() function was the one that i was looking for.  

---

### Answer by username_1 on 2016-01-02. Score: 1

Not Java, but interesting to examine as a reference to explore Java functionality with this fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc being a secp256k1 elliptic curve private key.

1. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx sha256 | bx ripemd160 | bx wrap-encode -v 0 | bx base58-encode`
   **1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln**
2. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx sha256 | bx ripemd160 | bx base58check-encode -v 0`
   **1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln**
3. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160 | bx base58check-encode -v 0`
   **1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln**
4. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160 | bx address-encode -v 0`
   **1KNogjhyQ3fSPGpzgAv8gSG5WLVN8L39Ln**
5. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public | bx bitcoin160 | bx address-encode -v 0`
   **1FbGdbUU1ibBtanPTLAuMTAJ4Y9HkatkcX**
6. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public`
   **02cf90dc2b34937fff7cf1eb4b260f1e5610231134b864761e508505938bbef8fc**
7. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u`
   **04cf90dc2b34937fff7cf1eb4b260f1e5610231134b864761e508505938bbef8fc00aeb265797336b74146e018da7b78070f1f1072540a2c3fe83637ca5d605b3c**
8. `% echo fc8fba997174132184998ab82b28e441e80c73236ccaf8b6a1efadc33febecfc | bx ec-to-public -u | bx bitcoin160`
   **c991f856a2992c877d3923298e67b88fe61e6c76**


---

