<p>See <a href="https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/base58.cpp#L124" rel="nofollow noreferrer">src/base58.cpp Line 124</a>:</p>

<pre><code>std::string EncodeBase58Check(const std::vector&lt;unsigned char&gt;&amp; vchIn)
{
    // add 4-byte hash check to the end
    std::vector&lt;unsigned char&gt; vch(vchIn);
    uint256 hash = Hash(vch.begin(), vch.end());
    vch.insert(vch.end(), (unsigned char*)&amp;hash, (unsigned char*)&amp;hash + 4);
    return EncodeBase58(vch);
}
</code></pre>

<p>As you can see, the data <code>vch</code> is hashed, then the first 4 bytes of the hash are appended to the end of <code>vch</code> before base58 encoding.</p>

CC BY-SA 4.0
2018-09-06T15:33:26.390Z
Thank you so much for your answer. Stupid me, I ask the wrong question, what I want ask is the source code to attach the prefix not checksum. would you please tell me which source to attach the prefix before do Base58?
yrm23
CC BY-SA 4.0
2018-09-06T15:43:34.430Z
I think you may be looking for these lines: https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/base58.cpp#L226. Note this has changed in the latest 0.17 release candidate to https://github.com/bitcoin/bitcoin/blob/v0.17.0rc3/src/key_io.cpp#L29
JBaczuk
CC BY-SA 4.0
2018-09-06T15:23:09.080Z
2018-09-06T15:28:26.847Z
2018-09-06T15:28:26.847Z
JBaczuk
<p>Can anyone tell me the specified source code to make "checksum bits appended", before doing Base58 conversion? Thanks very much!!!!</p>

<address><base58>
Which source code to make "checksum bits appended"
yrm23
# Which source code to make "checksum bits appended"

(Asked by: username_0 on 2018-09-06)

Can anyone tell me the specified source code to make "checksum bits appended", before doing Base58 conversion? Thanks very much!!!!

**Tags:** address, base58


---

## 1 answers

### Answer by username_1 on 2018-09-06. Score: 1

See [src/base58.cpp Line 124](https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/base58.cpp#L124):

```
std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn)
{
    // add 4-byte hash check to the end
    std::vector<unsigned char> vch(vchIn);
    uint256 hash = Hash(vch.begin(), vch.end());
    vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
    return EncodeBase58(vch);
}

```

As you can see, the data `vch` is hashed, then the first 4 bytes of the hash are appended to the end of `vch` before base58 encoding.

> **Comments:**
> **username_0**: Thank you so much for your answer. Stupid me, I ask the wrong question, what I want ask is the source code to attach the prefix not checksum. would you please tell me which source to attach the prefix before do Base58?  
> **username_1**: I think you may be looking for these lines: https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/base58.cpp#L226. Note this has changed in the latest 0.17 release candidate to https://github.com/bitcoin/bitcoin/blob/v0.17.0rc3/src/key_io.cpp#L29  

---

