Sample code for 30+ languages & platforms
Dart

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

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final jws = CkJws();

  // Set the payload from a StringBuilder.
  final sbPayload = CkStringBuilder();
  sbPayload.append('This is the content to sign.');

  final bIncludeBom = false;
  try {
    jws.setPayloadSb(sbPayload, 'utf-8', bIncludeBom);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('Payload set.');
}