Visual FoxPro
Visual FoxPro
Get the JWS Payload into BinData
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayloadBd, which writes the payload of a loaded JWS as raw bytes into a BinData.
Background. This is used when the payload is binary. In practice, validate the signature before trusting the payload.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loJws
LOCAL lcJwsCompact
LOCAL loBdPayload
lnSuccess = 0
loJws = CreateObject('Chilkat.Jws')
* Load the JWS compact serialization.
lcJwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
lnSuccess = loJws.LoadJws(lcJwsCompact)
IF (lnSuccess = 0) THEN
? loJws.LastErrorText
RELEASE loJws
CANCEL
ENDIF
* Get the JWS payload as raw bytes into a BinData.
loBdPayload = CreateObject('Chilkat.BinData')
lnSuccess = loJws.GetPayloadBd(loBdPayload)
IF (lnSuccess = 0) THEN
? loJws.LastErrorText
RELEASE loJws
RELEASE loBdPayload
CANCEL
ENDIF
? "Payload is " + STR(loBdPayload.NumBytes) + " bytes."
RELEASE loJws
RELEASE loBdPayload