<p>std::string BIP39SeedMaker::checksum(cpp_int v)
{
int binSize = binary(v).size();
std::string hash = sha.digest(v.str());
std::string hashBin = binary(cpp_int(&quot;0x&quot;+hash));
return hashBin.substr(0, binSize/32);
}</p>

CC BY-SA 4.0
2024-11-24T01:11:20.680Z
2024-11-24T01:11:20.680Z
Ayoub  5115 sershti
<p>From what i've read, the checksum is just a basic SHA-256 hashed string, when only taking (Bitlen/32) bits of the hashed string.</p>
<p>Yet when I do it, I get incorrect values (resulting in incorrect last words)
This is my implementation of the checksum calculator.
I've implemented the hashing algorithm by myself, but there shouldnt be any issues with it.</p>
<pre class="lang-cpp prettyprint-override"><code>std::string BIP39SeedMaker::checksum(cpp_int v)
{
    int binSize = binary(v).size();
    std::string hash = sha.digest(v.str());
    std::string hashBin = binary(cpp_int(&quot;0x&quot;+hash));
    return hashBin.substr(0, binSize/32);
}
</code></pre>
<p>Please let me know if you see anything wrong, im really confused</p>

<mnemonic-seed><bip><c++><checksum>
BIP39's checksum generation
DayDrunk
# BIP39's checksum generation

(Asked by: username_0 on 2024-11-22)

From what i've read, the checksum is just a basic SHA-256 hashed string, when only taking (Bitlen/32) bits of the hashed string.
Yet when I do it, I get incorrect values (resulting in incorrect last words)
This is my implementation of the checksum calculator.
I've implemented the hashing algorithm by myself, but there shouldnt be any issues with it.
std::string BIP39SeedMaker::checksum(cpp_int v)
{
    int binSize = binary(v).size();
    std::string hash = sha.digest(v.str());
    std::string hashBin = binary(cpp_int("0x"+hash));
    return hashBin.substr(0, binSize/32);
}

Please let me know if you see anything wrong, im really confused

**Tags:** mnemonic-seed, bip, c++, checksum


---

## 1 answers

### Answer by username_1 on 2024-11-24. Score: -1

std::string BIP39SeedMaker::checksum(cpp\_int v)
{
int binSize = binary(v).size();
std::string hash = sha.digest(v.str());
std::string hashBin = binary(cpp\_int("0x"+hash));
return hashBin.substr(0, binSize/32);
}


---

