hi all
I have faced a problem in using HMAC of cryptopp library in decoding section.
I have used the flowing code for encoding the planText and it works okay
this code is described in this link [
HMAC - Crypto++ Wiki[
^]]
AutoSeededRandomPool prng;
SecByteBlock key(16);
prng.GenerateBlock(key, key.size());
string plain = "HMAC Test";
string mac, encoded;
encoded.clear();
StringSource ss1(key, key.size(), true,
new HexEncoder(
new StringSink(encoded)
)
);
cout << "key: " << encoded << endl;
cout << "plain text: " << plain << endl;
try
{
HMAC< SHA256 > hmac(key, key.size());
StringSource ss2(plain, true,
new HashFilter(hmac,
new StringSink(mac)
)
);
}
catch (const CryptoPP::Exception& e)
{
cerr << e.what() << endl;
exit(1);
}
encoded.clear();
StringSource ss3(mac, true,
new HexEncoder(
new StringSink(encoded)
)
);
cout << "hmac: " << encoded << endl;
What I have tried:
now for decoding that on the other side
I read this link but it didn't help me
HexDecoder - Crypto++ Wiki[
^]
and this section doesn't return the plaintext
string decoded;
StringSource ss(encoded, true,
new HexDecoder(
new StringSink(decoded)
)
);
I Will be very grateful for any advice