BackgroundChacha.poly1305Aead constructor

BackgroundChacha.poly1305Aead({
  1. CryptographyChannelPolicy? channelPolicy,
  2. Random? random,
})

Constructs Chacha20.poly1305Aead that's optimized to use compute.

The channelPolicy can be used to choose which computations are done in the background and which computations are not. The default FlutterCipher.defaultChannelPolicy forces small encrypt / decrypt call to be computed in the same isolate.

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

Implementation

BackgroundChacha.poly1305Aead({
  CryptographyChannelPolicy? channelPolicy,
  Random? random,
})  : channelPolicy = random != null
          ? CryptographyChannelPolicy.never
          : (channelPolicy ?? BackgroundCipher.defaultChannelPolicy),
      super.constructor(random: random);