Sample code for 30+ languages & platforms
Unicode C++

Get the Entire Loaded JWE Structure

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.

Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkJweW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkJweW jwe;

    //  Load the JWE.
    const wchar_t *jweCompact = L"eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>";
    success = jwe.LoadJwe(jweCompact);
    if (success == false) {
        wprintf(L"%s\n",jwe.lastErrorText());
        return;
    }

    //  Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
    //  decoded or merged JOSE header.
    CkJsonObjectW json;
    success = jwe.GetHeader(json);
    if (success == false) {
        wprintf(L"%s\n",jwe.lastErrorText());
        return;
    }

    json.put_EmitCompact(false);
    wprintf(L"%s\n",json.emit());
    }