encrypt method
Implementation
@override
Future<String?> encrypt({
required String tag,
required String message,
required String sharedPreferences,
}) async {
var iv = await getIV(key: tag, sharedPreferences: sharedPreferences);
log('iv sp : $iv');
final res = await methodChannel.invokeMethod<String?>(
'encrypt',
{
'tag': tag,
'message': message,
'iv': iv,
},
);
if (res == null) return null;
var jsonRes = json.decode(res);
if (iv == null) {
log('iv new : ${jsonRes['iv']}');
await setIV(
key: tag,
value: jsonRes['iv'],
sharedPreferences: sharedPreferences,
);
}
return jsonRes['ciphertext'];
}