Sample code for 30+ languages & platforms
AutoIt

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

AutoIt
Local $bSuccess = False

$oJwe = ObjCreate("Chilkat.Jwe")

;  Load the JWE.
Local $sJweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
$bSuccess = $oJwe.LoadJwe($sJweCompact)
If ($bSuccess = False) Then
    ConsoleWrite($oJwe.LastErrorText & @CRLF)
    Exit
EndIf

;  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.
$oJson = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJwe.GetProtectedHeader($oJson)
If ($bSuccess = False) Then
    ConsoleWrite($oJwe.LastErrorText & @CRLF)
    Exit
EndIf

$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)