Skip to content

Commit

Permalink
Add utility to decrypt backups
Browse files Browse the repository at this point in the history
  • Loading branch information
afilini committed Sep 30, 2024
1 parent ce76812 commit 32a1780
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sdk/src/bin/decrypt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = std::env::args().collect::<Vec<_>>();

if args.len() < 2 {
return Err(format!("Usage: {} <enrypted_file>", args[0]).into())
}

let path = &args[1];
let file = std::fs::read(path)?;

eprint!("Type encryption key followed by enter: ");

let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer)?;
let buffer = buffer.trim();

let data = model::EncryptedBackupData::decrypt(&file, &buffer).map_err(|_| "Invalid key")?;
eprintln!("{:#?}", data);

Ok(())
}

0 comments on commit 32a1780

Please sign in to comment.