Why isn't this program printing out hex values?
<p>It's been a long time since I've touched C++ and I've never been quite fluent in the language, so forgive my ignorance.</p>

<p>I've written the following little program to mess around with XOR encryption:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include "string.h"

using std::cout;
using std::endl;
using std::hex;
using std::string;

string cipher(string msg, char key);

int main(void)
{
    string msg = "Now is the winter of our discontent, made glorious summer by this sun of York.";
    char key = 's';  // ASCII 115

    string ctext = cipher(msg, key);

    cout &lt;&lt; "Plaintext:  " &lt;&lt; msg &lt;&lt; endl;
    cout &lt;&lt; "Ciphertext (hex):  ";
    for (int i = 0; i &lt; ctext.size(); i++)
        cout &lt;&lt; hex &lt;&lt; ctext[i];

    return 0;
}

string cipher(string msg, char key)
/*
    Symmetric XOR cipher
*/
{
    for(int i = 0; i &lt; msg.size(); i++)
        msg[i] ^= key;

    return msg;
}
</code></pre>

<p>This code outputs the following:</p>

<pre><code>Plaintext:  Now is the winter of our discontent, made glorious summer by this sun of York.
Ciphertext (hex):  =SSSSSS_SSSS
SSSS*]
</code></pre>

<p>Why can I not get the hex values to output?  What am I doing wrong?</p>

<p>Also, any general advice is appreciated.</p>
