A serious question this time.
I'm writing a C++ implementation of a DES encryptor (yeah, I know, but it's not really a problem with the encryptor code as such). As a bit of background, the DES algorithm consists of 3 steps.
1) Derive 16 subkeys from a user supplied key
2) Encrypt data with those subkeys
3) decrypt data with those subkeys
From this, and wanting to keep it as OO as possible, I decided to create an encryptor class. The constructor for this class is the part that derives the subkeys. There is an encrypt method in this class, and a decrypt method in this class.
First Q. Does this seem a reasonable way to structure my class? This way, for each change of key I can create a new encryptor object, ready to call the encrypt / decrypt methods.
Next Q. Can I call functions from my constructor? If so how - where do I put the definitions etc.
Last Q.
I really don't like passing that char array to the constructor. Is there a way I can pass a pointer instead??Code:<snip> class clsInitKeys { char strKeyString[17]; char strKeyn[17][49]; public: char* GetKey(int x); clsInitKeys(char y[17] = "0123456789ABCDEF"); }; <snip> clsInitKeys::clsInitKeys(char y[17]) { strcpy (strKeyString, y); <snip> int main(void) { char key[17] = "0123456789abcdef"; <snip>
THX,
Rob.