/**************************************************************
* Encrypts a string using "cryptKey" string defined
* in the header file.
* Uses XOR encryption.
* (this is why the same function is used to both encryption and
* decryption).
* The whole key is continuously applied at a time to a part
* of the string until the string ends.
/************************************************************
char* CMetricFunctions::cptfnEncryptString (char* strInputString)
{
int i = 0;
BOOL isEndOfStr = FALSE;
char* strPtr = strInputString;
// keep encryting until string ends or key string ends
// sizeOfKey = size of encryption key which is 11 chars
while ((!isEndOfStr) || (i < sizeOfKey))
{
if (i == sizeOfKey)
i = 0;
*strPtr = *strPtr ^ strCryptKey[i];
strPtr++;
if (*strPtr == ''\0'')
isEndOfStr = TRUE;
i++;
}
return strPtr;
}
char* CMetricFunctions::cptfnDecryptString (char* strInputString)
{
char* strPtr = strInputString;
// keep encryting until string ends or key string ends
for (int i=0; i < sizeOfKey; i++)
{
*strPtr ^= strCryptKey[i];
strPtr++;
}
return strInputString;
}