I'm not sure of the purpose of the stringstream here:
1 2 3 4 5
for (int x = 0; x < msgCount; x++)
{
//convert string to char
ss << msg;
ss >> letter;
(edit: I suppose the stringstream, though just adding an extra layer of complexity, could work if it was assigned the value before the loop begins, rather than repeatedly inside the body of the loop. But still I suggest, remove it completely).
You could just do
1 2 3 4 5
for (int x = 0; x < msgCount; x++)
{
//convert string to char
char letter = msg.at(x);
Or msg[x] instead of the at() function.
Or better, a range-based for loop:
1 2 3 4 5
for (char letter : msg)
{
// convert chars to encrypted text
switch (letter)
{
Notice I declared letter within the loop - it's good to limit the scope of variables to just the place where they are used. it avoids clutter and confusion in the rest of the code.
One comment now that the previous problem is fixed.
You should call srand() just once at the start of main().
Because you have it inside a loop, which will probably execute in much less time than 1 second, on each pass of the loop, srand() will be re-seeded with the same value (because the value of time(0) is unchanged). That means all the 'random' numbers will usually be identical. Once in a while the program may execute at the very moment that the time changes from one second to the next, but that still only gives two seed values, hence all the random numbers will be one of two values.
The rest of the code could probably be improved too, but I'm not sure what algorithm you are using for the encryption, so it's hard to advise properly.