Sample code for 30+ languages & platforms
Dart

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Dart Downloads

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

void main() {
  final crypt = CkCrypt2();

  final bdEncrypted = CkBinData();
  final sbPlainText = CkStringBuilder();

  sbPlainText.append('Text to be encrypted');

  // ...
  // Set the secret key ...
  // Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
  // Set the IV if needed ...
  // ...

  crypt.charset = 'utf-8';

  try {
    crypt.encryptSb(sbPlainText, bdEncrypted);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }
}