Unicode C++
Unicode C++
Get the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetProtectedHeader, which copies the decoded shared JWE protected header into a JsonObject.
Background. Only the protected header is returned; it is not merged with the shared unprotected header or any per-recipient header.
Chilkat Unicode C++ Downloads
#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 decoded shared JWE protected header into a JsonObject. Only the protected header is
// returned; it is not merged with the unprotected or per-recipient headers.
CkJsonObjectW json;
success = jwe.GetProtectedHeader(json);
if (success == false) {
wprintf(L"%s\n",jwe.lastErrorText());
return;
}
json.put_EmitCompact(false);
wprintf(L"%s\n",json.emit());
}