PowerShell
PowerShell
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 PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$jwe = New-Object Chilkat.Jwe
# Load the JWE.
$jweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
$success = $jwe.LoadJwe($jweCompact)
if ($success -eq $false) {
$($jwe.LastErrorText)
exit
}
# 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-Object Chilkat.JsonObject
$success = $jwe.GetProtectedHeader($json)
if ($success -eq $false) {
$($jwe.LastErrorText)
exit
}
$json.EmitCompact = $false
$($json.Emit())