Sample code for 30+ languages & platforms
C++

Obfuscate String

Demonstrates how to obfuscate and unobfuscate a string.

Chilkat C++ Downloads

C++
#include <CkStringBuilder.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkStringBuilder sb;

    const char *s = "Hello World!";

    sb.Append(s);
    std::cout << sb.getAsString() << "\r\n";

    //  Output is "Hello World!";

    //  Obfuscate the string.
    //  This is NOT encryption.  It's just a simple obfuscation.
    sb.Obfuscate();
    std::cout << sb.getAsString() << "\r\n";

    //  Output is 2GsgGhbSQVyG8Vb9

    //  -------------------------
    //  Unobfuscate.
    CkStringBuilder sb2;
    const char *s2 = "2GsgGhbSQVyG8Vb9";
    sb2.Append(s2);
    sb2.Unobfuscate();

    std::cout << sb2.getAsString() << "\r\n";

    //  Output is "Hello World!";
    }