toSync method

  1. @override
DartAesGcm toSync()
override

Returns a synchronous, pure Dart implementation of this cipher.

Pure Dart implementations can be slower than implementations that use platform APIs. Therefore you shouldn't use this method unless you really need to.

Example

import 'package:cryptography/cryptography.dart';

void main() {
  final cipher = Chacha20.poly1305Aead().toSync();
  final secretKey = cipher.newSecretKeySync();
  final secretBox = cipher.encryptSync(
    [1,2,3],
    secretKey,
  );
}

Implementation

@override
DartAesGcm toSync() {
  return DartAesGcm(
    secretKeyLength: secretKeyLength,
    nonceLength: nonceLength,
    random: random,
  );
}