HashVerificationFilter and "message hash or MAC not valid" exception
<p>In Crpto++ one can easily use pipeline to hash an input. </p>

<pre><code>std::string out;
CryptoPP::SHA256 sha;
CryptoPP::StringSource ss(input,true,
                          new CryptoPP::HashFilter(sha,
                              new CryptoPP::HexEncoder(
                                  new CryptoPP::StringSink(out))));
</code></pre>

<p>Now inorder to verify a gives message x produces the same hash output, I would like to use HashVerificationFilter. I have tried it but it doesn't work. Anyone know the correct syntax ?</p>

<pre><code>const int flags = CryptoPP::HashVerificationFilter::THROW_EXCEPTION | CryptoPP::HashVerificationFilter::HASH_AT_END;
CryptoPP::SHA256 sha;
try
{
    CryptoPP::StringSource ss(input + out, true,
                              new CryptoPP::HashVerificationFilter(sha, NULL , flags));
}
catch(const CryptoPP::Exception&amp; e)
{
    std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
    exit(1);
}
</code></pre>

<p>I get the output : </p>

<pre><code>HashVerificationFilter: message hash or MAC not valid
</code></pre>