Archived Forum Post

Index of archived forum posts


decryptStringENC method description and example do not match

Jan 03 '13 at 17:34

the decryptStringENC method for the CkCrypt2 class shows that a bool is returned with the decrypted string being returned as the 2nd parameter. The C++ example shows the method being used with one parameter and the decrypted string being returned as the result of the method. Which one is correct?

Also, can a CkString be cast to a C++ "string" type successfully?


Each Chilkat C++ method that returns a string has two versions — an upper-case version that returns the string in a CkString (always the last argument), and a lower-case version that returns a "const char *".

For example, in the CkEmail class:

bool GetHeaderField(const char *fieldName, CkString &outFieldValue);
const char *getHeaderField(const char *fieldName);
The lower-case method returning a "const char *" returns a pointer to memory that may be overwritten in subsequent calls. Therefore, make sure to copy the string to a safe place immediately before making additional calls on the same Chilkat object instance. (Only methods that also return "const char *" would overwrite the memory from a previous call.)

The upper-case version of the method returns the string in a CkString object. It is an output-only argument, meaning that the CkString contents are replaced, not appended.