encrypt method
Encrypts a cleartext.
Parameter keyStreamIndex
allows you to choose offset in the keystream.
For other arguments, see Cipher.encrypt
.
Implementation
@override
Future<SecretBox> encrypt(
List<int> clearText, {
required SecretKey secretKey,
List<int>? nonce,
List<int> aad = const <int>[],
int keyStreamIndex = 0,
Uint8List? possibleBuffer,
}) {
if (!kIsWeb &&
isSupportedPlatform &&
FlutterCryptography.isPluginPresent &&
channelPolicy.matches(length: clearText.length)) {
return FlutterCipher.encryptWithPlugin(
name: channelCipherName,
cipher: this,
fallback: this.fallback,
clearText: clearText,
secretKey: secretKey,
nonce: nonce,
aad: aad,
);
}
final fallback = this.fallback;
if (fallback == null) {
throw UnsupportedError('No fallback was specified.');
}
return fallback.encrypt(
clearText,
secretKey: secretKey,
nonce: nonce,
aad: aad,
);
}