FlutterAesGcm constructor

FlutterAesGcm({
  1. required int secretKeyLength,
  2. CryptographyChannelPolicy? channelPolicy,
  3. AesGcm? fallback,
  4. Random? random,
})

Constructs Flutter-optimized AesGcm with the given secretKeyLength.

The channelPolicy can be used to choose which requests are sent to the plugin implementation (using a Flutter MethodChannel) and which ones are handled in the same isolate. The default FlutterCipher.defaultChannelPolicy forces small encrypt / decrypt calls to be handled in the same isolate.

When operating system APIs are not available fallback is used. The default fallback implementation is BackgroundAesGcm.

If you want deterministic key generation for testing, you can pass a Random instance that returns the same sequence of bytes every time.

Implementation

FlutterAesGcm({
  required this.secretKeyLength,
  CryptographyChannelPolicy? channelPolicy,
  AesGcm? fallback,
  Random? random,
})  : fallback = fallback ??
          BackgroundAesGcm(
            secretKeyLength: secretKeyLength,
            random: random,
          ),
      channelPolicy = channelPolicy ?? FlutterCipher.defaultChannelPolicy,
      super.constructor(random: random);