readEncryptedData static method
Read and decrypt content
Implementation
static Future<String?> readEncryptedData(String passphrase) async {
final filePath = await _getPublicDocumentsPath();
final file = File(filePath);
if (!await file.exists()) return null;
final content = await file.readAsString();
final jsonMap = jsonDecode(content);
final salt = base64Decode(jsonMap['salt']);
final iv = base64Decode(jsonMap['iv']);
final data = base64Decode(jsonMap['data']);
final key = await _deriveKey(passphrase, salt);
final decrypted = await _decrypt(data, key, iv);
return utf8.decode(decrypted);
}