Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Jws
oleobject loo_SbPayload
integer li_BIncludeBom

li_Success = 0

loo_Jws = create oleobject
li_rc = loo_Jws.ConnectToNewObject("Chilkat.Jws")
if li_rc < 0 then
    destroy loo_Jws
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Set the payload from a StringBuilder.
loo_SbPayload = create oleobject
li_rc = loo_SbPayload.ConnectToNewObject("Chilkat.StringBuilder")

loo_SbPayload.Append("This is the content to sign.")

li_BIncludeBom = 0
li_Success = loo_Jws.SetPayloadSb(loo_SbPayload,"utf-8",li_BIncludeBom)
if li_Success = 0 then
    Write-Debug loo_Jws.LastErrorText
    destroy loo_Jws
    destroy loo_SbPayload
    return
end if

Write-Debug "Payload set."


destroy loo_Jws
destroy loo_SbPayload