aes256EncryptBytes method
Future<List<int>>
aes256EncryptBytes(
{ - required FlutterAesGcm algorithm,
- required String rawKey,
- required int rawKeyLength,
- required Uint8List data,
- required int iteration,
- required int saltLength,
- required int ivLength,
})
Implementation
Future<List<int>> aes256EncryptBytes({
required FlutterAesGcm algorithm,
required String rawKey,
required int rawKeyLength,
required Uint8List data,
required int iteration,
required int saltLength,
required int ivLength
}) async {
final salt = randomBytes(saltLength);
final iv = randomBytes(ivLength);
final secretKey = await _deriveKey(rawKey, rawKeyLength, salt, iteration);
final secretBox = await algorithm.encrypt(
data,
secretKey: secretKey,
nonce: iv,
);
final List<int> result = salt + secretBox.nonce + secretBox.cipherText + secretBox.mac.bytes;
return result;
}