Sample code for 30+ languages & platforms
Objective-C

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 Objective-C Downloads

Objective-C
#import <CkoJws.h>
#import <CkoStringBuilder.h>

BOOL success = NO;

CkoJws *jws = [[CkoJws alloc] init];

//  Set the payload from a StringBuilder.
CkoStringBuilder *sbPayload = [[CkoStringBuilder alloc] init];
[sbPayload Append: @"This is the content to sign."];

BOOL bIncludeBom = NO;
success = [jws SetPayloadSb: sbPayload charset: @"utf-8" includeBom: bIncludeBom];
if (success == NO) {
    NSLog(@"%@",jws.LastErrorText);
    return;
}

NSLog(@"%@",@"Payload set.");