Swift
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
let jws = CkoJws()!
// Set the payload from a StringBuilder.
let sbPayload = CkoStringBuilder()!
sbPayload.append(value: "This is the content to sign.")
var bIncludeBom: Bool = false
success = jws.setPayloadSb(sbPayload: sbPayload, charset: "utf-8", includeBom: bIncludeBom)
if success == false {
print("\(jws.lastErrorText!)")
return
}
print("Payload set.")
}