BackgroundAesGcm constructor
BackgroundAesGcm({
- required int secretKeyLength,
- int nonceLength = AesGcm.defaultNonceLength,
- CryptographyChannelPolicy? channelPolicy,
- Random? random,
Constructs AesGcm
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
BackgroundAesGcm({
required this.secretKeyLength,
this.nonceLength = AesGcm.defaultNonceLength,
CryptographyChannelPolicy? channelPolicy,
Random? random,
}) : assert(secretKeyLength == 16 ||
secretKeyLength == 24 ||
secretKeyLength == 32),
channelPolicy = random != null
? CryptographyChannelPolicy.never
: (channelPolicy ?? BackgroundCipher.defaultChannelPolicy),
super.constructor(random: random);