Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

set jws [new_CkJws]

#  Set the payload from a StringBuilder.
set sbPayload [new_CkStringBuilder]

CkStringBuilder_Append $sbPayload "This is the content to sign."

set bIncludeBom 0
set success [CkJws_SetPayloadSb $jws $sbPayload "utf-8" $bIncludeBom]
if {$success == 0} then {
    puts [CkJws_lastErrorText $jws]
    delete_CkJws $jws
    delete_CkStringBuilder $sbPayload
    exit
}

puts "Payload set."

delete_CkJws $jws
delete_CkStringBuilder $sbPayload