Unicode C
Unicode 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 Unicode C Downloads
#include <C_CkJwsW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkJwsW jws;
HCkStringBuilderW sbPayload;
BOOL bIncludeBom;
success = FALSE;
jws = CkJwsW_Create();
// Set the payload from a StringBuilder.
sbPayload = CkStringBuilderW_Create();
CkStringBuilderW_Append(sbPayload,L"This is the content to sign.");
bIncludeBom = FALSE;
success = CkJwsW_SetPayloadSb(jws,sbPayload,L"utf-8",bIncludeBom);
if (success == FALSE) {
wprintf(L"%s\n",CkJwsW_lastErrorText(jws));
CkJwsW_Dispose(jws);
CkStringBuilderW_Dispose(sbPayload);
return;
}
wprintf(L"Payload set.\n");
CkJwsW_Dispose(jws);
CkStringBuilderW_Dispose(sbPayload);
}