encrypt function
Implementation
Future<String> encrypt({required String str, String? key}) async {
key = key ?? MD<ApiConstants>().encryptKey;
try {
final encrypter = _buildEncrypter(key);
final encrypted =
encrypter.encrypt(str, iv: IV(Uint8List.fromList(_buildIV(key))));
return encrypted.base64;
} catch (e) {
throw Exception('Encryption error: $e');
}
}