doby/src/bin/headers.rs

24 lines
882 B
Rust
Raw Normal View History

2021-06-30 15:24:15 +02:00
use std::{env, fs::File, io::{self, Read}};
use doby::{MAGIC_BYTES, crypto::EncryptionParams};
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
let mut file = File::open(&args[1])?;
let mut magic_bytes = vec![0; MAGIC_BYTES.len()];
file.read(&mut magic_bytes)?;
if magic_bytes == MAGIC_BYTES {
match EncryptionParams::read(&mut file)? {
Some(params) => {
2021-11-13 19:08:28 +01:00
println!("Argon2 time cost: {}", params.argon2.t_cost());
println!("Argon2 memory cost: {}KB", params.argon2.m_cost());
println!("Argon2 parallelism cost: {}", params.argon2.p_cost());
2021-06-30 15:24:15 +02:00
println!("Encryption cihpher: {}", params.cipher);
}
2021-11-13 19:08:28 +01:00
None => eprintln!("Invalid parameters")
2021-06-30 15:24:15 +02:00
}
} else {
eprintln!("Doby format not recognized.");
}
Ok(())
}