Lianja
Lianja
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 Lianja Downloads
llSuccess = .F.
loJwe = createobject("CkJwe")
// Load the JWE.
lcJweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
llSuccess = loJwe.LoadJwe(lcJweCompact)
if (llSuccess = .F.) then
? loJwe.LastErrorText
release loJwe
return
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.
loJson = createobject("CkJsonObject")
llSuccess = loJwe.GetProtectedHeader(loJson)
if (llSuccess = .F.) then
? loJwe.LastErrorText
release loJwe
release loJson
return
endif
loJson.EmitCompact = .F.
? loJson.Emit()
release loJwe
release loJson