Sample code for 30+ languages & platforms
Dart

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat Dart Downloads

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

void main() {
  final bd = CkBinData();

  final s = 'A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump';

  bd.appendString(s, 'utf-8');

  final strBase64 = bd.getEncoded('base64');
  print(strBase64);

  // To decode:
  final bd2 = CkBinData();
  bd2.appendEncoded(strBase64, 'base64');

  final decoded = bd2.getString('utf-8');
  print(decoded);
}