title: How to convert string to byte array
body: <p>I have a byte array which contain hex value. To store it I encode it to string, and to retrieve it first I decode it to string, how can I convert it to byte array then?</p>
  
  <p>Here is the code :</p>
  
  <p>I create byte array here:</p>
  
  <pre><code>AutoSeededRandomPool prng;
  byte key[CryptoPP::AES::MAX_KEYLENGTH];
  
  prng.GenerateBlock(key, sizeof(key));
  </code></pre>
  
  <p>and then encode it as string with following:</p>
  
  <pre><code>string encoded;
  encoded.clear();
  StringSource(key, sizeof(key), true,
      new HexEncoder(
          new StringSink(encoded)
      ) // HexEncoder
  ); // StringSource
  </code></pre>
  
  <p>Now to get main byte array, first I decode it:</p>
  
  <pre><code>string decodedkey;
  StringSource ssk(encoded, true /*pumpAll*/,
  new HexDecoder(
      new StringSink(decodedkey)
      ) // HexDecoder
  ); // StringSource
  </code></pre>
  
  <p>but I don't know how to reach to byte array. </p>
  
  <pre><code>byte key[CryptoPP::AES::MAX_KEYLENGTH]; 
  </code></pre>