retrieve method
Retrieves securely stored data.
Returns an empty map if no data is stored or decryption fails.
Implementation
Future<Map<String, String>> retrieve() async {
if (!_credentialsFile.existsSync()) {
return {};
}
try {
final key = await _getMachineKey();
final encrypted = await _credentialsFile.readAsBytes();
final decrypted = _decrypt(encrypted, key);
final jsonData = utf8.decode(decrypted);
final decoded = json.decode(jsonData) as Map<dynamic, dynamic>;
return Map<String, String>.from(decoded);
} catch (e) {
// If decryption fails, return empty map
return {};
}
}