I am a beginner in Crypto++ and i am trying to convert a hex string to a byte array. I have searched a whole lot on internet for this to little help. Here is my code:
1 2 3 4
string encoded="140b41b22a29beb4061bda66b6747e14";
string recovered1;
StringSource(encoded, true, new HexDecoder( new StringSink(recovered1) ) );
byte* key = (byte *) recovered1.data();
However when i try to re-covert the byte array key to a hex-string only 8 bytes are printed instead of 16. I have used the following code for it:
1 2
StringSource(key, sizeof(key), true, new HexEncoder( new StringSink(encoded)) );
cout << "key: " << encoded << endl;