encryptSync method
Implementation
SecretBox encryptSync(
List<int> clearText, {
required SecretKeyData secretKey,
List<int>? nonce,
List<int> aad = const <int>[],
int keyStreamIndex = 0,
Uint8List? possibleBuffer,
}) {
nonce ??= newNonce();
checkParameters(
length: clearText.length,
secretKey: secretKey,
nonceLength: nonce.length,
aadLength: aad.length,
keyStreamIndex: keyStreamIndex,
);
final state = newState();
state.initializeSync(
isEncrypting: true,
secretKey: secretKey,
nonce: nonce,
aad: aad,
keyStreamIndex: keyStreamIndex,
);
final cipherText = state.convertSync(
clearText,
possibleBuffer: possibleBuffer,
);
return SecretBox(
cipherText,
nonce: nonce,
mac: state.mac,
);
}