Original Post
I am currently trying to make a class file that encrypts strings I send to it using Caeser Cipher I send the following data and then I have had a problem. Currently I have a window with 2 edit boxes one edit box you type in the other outputs encrypted data or if you enter data into the output window (edit box)
it decrypts the data and puts it in the other window (edit box). As you type the data is gathered from one edit window and passed into this function encrypt. For some reason it only seems to encrypt the first few letters and does not encrypt ALL the data that is typed. Could someone look this over and see if they can find any problems with it? Thank you.
LPTSTR CCaeser::Encrypt(LPTSTR data)
{
LPSTR en;
int size = sizeof(data)+1;
char ch;
char dat[15000];
strncpy(dat,_strrev(data),size);
out.open("en.log");
for(int i = 0; i <= size; i++)
{
ch = Cipher(data);
data[i] = ch;
out << ch;
}
out.close();
LocalFree(dat);
return en;
}
char CCaeser::Cipher(char ch)
{
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char ciphered[] = "TUVWXYZABCDEFGHIJKLMNOPQRS";
for(int i=0; i<=sizeof(alpha); i++)
{
if(alpha[i] == towupper(ch))
{
return ciphered[i];
}
}
return ch;
}
Don''t click me!
Killer Eagle Software