AutoIt
AutoIt
Get a JWS Protected Header
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetProtectedH, which copies the decoded protected header of a signature into a JsonObject.
Background. The protected header is integrity-protected by the signature. Inspecting it (for example the
alg value) is useful before deciding how to validate.Chilkat AutoIt Downloads
Local $bSuccess = False
$oJws = ObjCreate("Chilkat.Jws")
; Load the JWS compact serialization.
Local $sJwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
$bSuccess = $oJws.LoadJws($sJwsCompact)
If ($bSuccess = False) Then
ConsoleWrite($oJws.LastErrorText & @CRLF)
Exit
EndIf
; Copy the decoded protected header of signature 0 into a JsonObject.
$oJson = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJws.GetProtectedH(0,$oJson)
If ($bSuccess = False) Then
ConsoleWrite($oJws.LastErrorText & @CRLF)
Exit
EndIf
$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)