Sample code for 30+ languages & platforms
C++

Example: Crypt2.EncodeString method

Demonstrates how to call the EncodeString method.

Chilkat C++ Downloads

C++
#include <CkCrypt2.h>

void ChilkatSample(void)
    {
    CkCrypt2 crypt;

    const char *s = "Hello World";

    std::cout << crypt.encodeString(s,"utf-8","hex") << "\r\n";
    //  Output: 48656C6C6F20576F726C64

    std::cout << crypt.encodeString(s,"utf-16","hex") << "\r\n";
    //  Output: 480065006C006C006F00200057006F0072006C006400

    std::cout << crypt.encodeString(s,"utf-8","base64") << "\r\n";
    //  Output: SGVsbG8gV29ybGQ=

    s = "électricité";

    std::cout << crypt.encodeString(s,"utf-8","hex") << "\r\n";
    //  Output: C3A96C6563747269636974C3A9

    std::cout << crypt.encodeString(s,"windows-1252","hex") << "\r\n";
    //  Output: E96C6563747269636974E9

    std::cout << crypt.encodeString(s,"windows-1252","hex_lower") << "\r\n";
    //  Output: e96c6563747269636974e9

    std::cout << crypt.encodeString(s,"utf-8","url") << "\r\n";
    //  Output: %C3%A9lectricit%C3%A9
    }