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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user