Unicode C++
Unicode C++
Set the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.SetProtectedHeader, which sets the integrity-protected JWE header from a JsonObject. The header specifies the key-management algorithm (alg) and content-encryption algorithm (enc).
Background. The protected header is integrity-protected and applies to all recipients. It is configured before encrypting.
Chilkat Unicode C++ Downloads
#include <CkJweW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
CkJweW jwe;
// Build the JWE protected header. The "alg" member names the key-management algorithm and the "enc"
// member names the content-encryption algorithm.
CkJsonObjectW header;
header.UpdateString(L"alg",L"A256KW");
header.UpdateString(L"enc",L"A256GCM");
// Set the protected header on the JWE. The protected header is integrity-protected and applies to
// all recipients.
success = jwe.SetProtectedHeader(header);
if (success == false) {
wprintf(L"%s\n",jwe.lastErrorText());
return;
}
wprintf(L"Protected header set.\n");
}