CONVERTING HEX TO BYTE

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;


PLEASE HELP ME!
and thanks for the help.
I have no idea what you are doing here, you show us nothing of your hex2byte conversion.
Nor what a StringSink is or indeed a StringSource.

When you searched the internet did you search this site?

http://www.cplusplus.com/forum/windows/97368/
http://www.cplusplus.com/forum/general/53397/
if key in your second code is byte* then this:

StringSource(key, sizeof(key), true, new HexEncoder( new StringSink(encoded)) );

is definitely wrong
Topic archived. No new replies allowed.