// SECURE.H - SecureString class definition // Algorithm taken from Michiel de Bruijn, "Keep Your Data // Under Lock and Key", in Visual Basic Programmers Journal, // Sept. 1995. #include #include #include class SecureString { public: SecureString(){ key[0] = '\0'; } // Default constructor. SecureString( const char * plain, const char * keyV ); // Construct a secure string from an existing string and a key. void Decode( char * buffer ); // Fill a pre-allocated buffer with the decoded string. void Encode( const char * plain, const char * keyV ); // Initialize key and encode a string. friend ostream & operator <<( ostream & os, const SecureString & S ); // Stream output operator. private: enum { keyMax = 50, stringMax = 1000 }; char key[keyMax+1]; // encryption key char data[stringMax+1]; // encrypted string unsigned int length; // length of string void Translate( const char * inputStr, char * outStr ) const; };