Add local backup/restore: encrypted .enc export to Download/loginvault, restore from list (no file_picker to avoid SDK conflict)

This commit is contained in:
cania
2026-08-13 14:47:14 +02:00
parent 92a3ca4d82
commit 7cb2ca42c5
8 changed files with 256 additions and 2 deletions

View File

@@ -26,4 +26,20 @@ class Encryptor {
final xored = _xorBytes(base64.decode(cipher), keyBytes);
return utf8.decode(xored);
}
/// Encrypt [plain] with a user password (for backup files).
/// Uses the password bytes as the XOR key so the backup is protected by the
/// app password, not the in-app constant key.
static String encryptWithPassword(String plain, String password) {
final keyBytes = utf8.encode(password);
final xored = _xorBytes(utf8.encode(plain), keyBytes);
return base64.encode(xored);
}
/// Decrypt a backup [cipher] produced by [encryptWithPassword].
static String decryptWithPassword(String cipher, String password) {
final keyBytes = utf8.encode(password);
final xored = _xorBytes(base64.decode(cipher), keyBytes);
return utf8.decode(xored);
}
}