forked from TwentyTwoHW/portal-software
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |