I'm about to rip my hair out. I have a class that is supposed to encrypt/decrypt and string. I had it declared in temporary instances (crypt_class([string]).encrypt([password])), but that was detrimental to the performance, so I created 1 instance in the function (seeing as it was used throughout, and it would be deconstructed anyway), which should speed it up (and it did significantly!).
Here's the problem, though: it seems to be encrypting and decrypting improperly now. I've tested it, and found that adding
void operator=(const crypt_class&)
member got it to work... but then from there I don't know what happens, the program saves, and when it tries to reload the data it fails (the data is not encrypted the same for some reason).
A test revealed somthing (and to be quite frank, I have a lot of very colorful words I want to throw around...):
1 2 3 4 5 6 7 8 9
|
crypt_class c;
c.set_pass(password);
c = [a string];
[a string] = c.decrypt();
//c.encrypt() and c.decrypt will return the decrypted and encrypted
//strings respectively.
cout<< "string = "<< [a string]<< endl;
cout<< "c = "<< c.encrypt()<< " decrypted: "<< c.decrypt()<< endl;
|
And the most peculiar thing was displayed: for both decrypted and encrypted values, the same string was shown, but the string that was "decrypted" was not the same.
I'm going mad over this. I will try to put together some working code when I have time... hopefully tomorrow. In the meantime mabey someone knows somthing about how classes work that could explain such 'behavior'...
Here is some stuff about the class I wrote, if it helps:
- All arguments passed to member functions are passed by const values, and by address...
- returning member variables is done by the following syntax:
return this->[var]
- constructors: (const string& and const char* are used to set a string variable... this variable is used to store text that is decrypted and encrypted, and this variable is modified when this happens.
I ask for speculation until I can put somthing together, that can be run...
Thanks for your time.