encryptData method
Encrypts the provided data
using the AES encryption algorithm and the generated encryption key.
Returns the encrypted data as a base64-encoded string.
Implementation
String encryptData(String data) {
try {
final algorithm = AES(_requiredKey!);
final enc = Encrypter(algorithm);
final encrypted = enc.encrypt(data, iv: _iv);
return encrypted.base64;
} catch (e) {
print('Encryption error: $e');
return data;
}
}