PHP
Chilkat2 PHP
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 PHP Downloads
<?php
use Chilkat2\JsonObject;
use Chilkat2\Jwe;
$jwe = new Jwe();
// Load the JWE.
$jweCompact = 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
try {
$jwe->LoadJwe($jweCompact);
// 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.
$json = new JsonObject();
$jwe->GetProtectedHeader($json);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
$json->EmitCompact = false;
echo $json->Emit(), "\n";