Unicode C
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
#include <C_CkJweW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkJweW jwe;
const wchar_t *jweCompact;
HCkJsonObjectW json;
success = FALSE;
jwe = CkJweW_Create();
// Load the JWE.
jweCompact = L"eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>";
success = CkJweW_LoadJwe(jwe,jweCompact);
if (success == FALSE) {
wprintf(L"%s\n",CkJweW_lastErrorText(jwe));
CkJweW_Dispose(jwe);
return;
}
// Copy the entire loaded JWE structure into a JsonObject. This is the full JWE representation, not a
// decoded or merged JOSE header.
json = CkJsonObjectW_Create();
success = CkJweW_GetHeader(jwe,json);
if (success == FALSE) {
wprintf(L"%s\n",CkJweW_lastErrorText(jwe));
CkJweW_Dispose(jwe);
CkJsonObjectW_Dispose(json);
return;
}
CkJsonObjectW_putEmitCompact(json,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(json));
CkJweW_Dispose(jwe);
CkJsonObjectW_Dispose(json);
}