Help With Basic Encryption/Decryption

while(!in.eof())
{
in >> ch;
char d = int(ch) + 10;
out << d;
}

while(!in.eof())
{
in >> ch;
char d = int(ch) - 10;
out << d;
}

The first while loop would be to encrypt it, and the second would decrypt it, the decrypting is not giving the original content. For example:

in = Hello
encrypt...
decrypt...
out = Hellooo

1
2
3
4
5
6
7
8
9
while ( in >> ch )
{
    out << char(ch+10) ;
}

while ( in >> ch )
{
    out << char(ch-10) ;
}


http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong
thank you so much!
Topic archived. No new replies allowed.