Sample code for 30+ languages & platforms
PHP

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 PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\JsonObject;
use Chilkat2\Jwe;

$jwe = new Jwe();

// Load the JWE.
$jweCompact = 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
try {
    $jwe->LoadJwe($jweCompact);

    // Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
    // decoded or merged JOSE header.
    $json = new JsonObject();
    $jwe->GetHeader($json);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

$json->EmitCompact = false;
echo $json->Emit(), "\n";