DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoJws
Variant vSbPayload
Handle hoSbPayload
Boolean iBIncludeBom
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatJws)) To hoJws
If (Not(IsComObjectCreated(hoJws))) Begin
Send CreateComObject of hoJws
End
// Set the payload from a StringBuilder.
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPayload
If (Not(IsComObjectCreated(hoSbPayload))) Begin
Send CreateComObject of hoSbPayload
End
Get ComAppend Of hoSbPayload "This is the content to sign." To iSuccess
Move False To iBIncludeBom
Get pvComObject of hoSbPayload to vSbPayload
Get ComSetPayloadSb Of hoJws vSbPayload "utf-8" iBIncludeBom To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoJws To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Payload set."
End_Procedure