PureBasic
PureBasic
Set the JWS Payload from a StringBuilder
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.SetPayloadSb, which sets the payload to be signed from a StringBuilder.
Background. JWS (JSON Web Signature) integrity-protects a payload with a signature or MAC. The header
alg names the algorithm; this example uses HMAC-SHA256 (HS256) with a symmetric MAC key.Chilkat PureBasic Downloads
IncludeFile "CkJws.pb"
IncludeFile "CkStringBuilder.pb"
Procedure ChilkatExample()
success.i = 0
jws.i = CkJws::ckCreate()
If jws.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Set the payload from a StringBuilder.
sbPayload.i = CkStringBuilder::ckCreate()
If sbPayload.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkStringBuilder::ckAppend(sbPayload,"This is the content to sign.")
bIncludeBom.i = 0
success = CkJws::ckSetPayloadSb(jws,sbPayload,"utf-8",bIncludeBom)
If success = 0
Debug CkJws::ckLastErrorText(jws)
CkJws::ckDispose(jws)
CkStringBuilder::ckDispose(sbPayload)
ProcedureReturn
EndIf
Debug "Payload set."
CkJws::ckDispose(jws)
CkStringBuilder::ckDispose(sbPayload)
ProcedureReturn
EndProcedure