Skip to content

Commit

Permalink
Add starting and ending time outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeder committed Sep 18, 2024
1 parent 90be4ac commit d914caa
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 12 deletions.
145 changes: 143 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Leonid Beder <[email protected]>"]
edition = "2021"
name = "slowkey"
version = "1.1.0"
version = "1.1.1"

[dependencies]
better-panic = "0.3.0"
Expand All @@ -25,6 +25,7 @@ serde_json = "1.0.128"
chacha20poly1305 = "0.10.1"
glob = "0.3.1"
indicatif = "0.17.8"
chrono = "0.4.38"

[dev-dependencies]
rstest = "0.18.2"
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Final result:
Key (hex) is (please highlight to see): 8ef994a0383b2a445d3f55a1251eb002
Finished in 49s
Start time: 2024-09-18 18:57:34
End time: 2024-09-18 18:58:26
Total running time: 52s
```
Please note that salt must be `16` bytes long, therefore shorter/longer salts will be SHA512 hashed and then truncated to `16` bytes:
Expand Down Expand Up @@ -298,7 +300,9 @@ Final result:
Key (hex) is (please highlight to see): 8ef994a0383b2a445d3f55a1251eb002
Finished in 26s
Start time: 2024-09-18 19:00:59
End time: 2024-09-18 19:01:25
Total running time: 25s
```
### Outputs
Expand All @@ -322,7 +326,9 @@ Key (hex) is (please highlight to see): 8ef994a0383b2a445d3f55a1251eb002
Key (base64) is (please highlight to see): jvmUoDg7KkRdP1WhJR6wAg==
Key (base58) is (please highlight to see): JezwF9TWYHNERQAi63dHcu
Finished in 50s
Start time: 2024-09-18 18:57:34
End time: 2024-09-18 18:58:26
Total running time: 52s
```
In addition to the above, the tool also supports saving the output to be encrypted and stored to the disk:
Expand All @@ -346,7 +352,9 @@ Key (hex) is (please highlight to see): 8ef994a0383b2a445d3f55a1251eb002
Saved encrypted output to "~/output.enc"
Finished in 50s
Start time: 2024-09-18 18:57:34
End time: 2024-09-18 18:58:26
Total running time: 52s
```
Let's use the `show-output` command to decrypt its contents:
Expand Down Expand Up @@ -408,7 +416,7 @@ Derived key: edada70cd27e31ddcfc41edba2f63a03418fc1acd352ff78eff149573c5e247f0e0
MIT License
Copyright (c) 2018 Leonid Beder
Copyright (c) 2024 Leonid Beder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 20 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
},
};
use base64::{engine::general_purpose, Engine as _};
use chrono::{DateTime, Utc};
use clap::{Parser, Subcommand};
use crossterm::style::Stylize;
use dialoguer::{theme::ColorfulTheme, Confirm, Password};
Expand All @@ -37,7 +38,7 @@ use std::{
path::PathBuf,
str::from_utf8,
thread,
time::{Duration, Instant},
time::{Duration, Instant, SystemTime},
};
use utils::{argon2id::Argon2idOptions, chacha20poly1305::ChaCha20Poly1305};

Expand Down Expand Up @@ -487,7 +488,8 @@ fn main() {
}
}

let start_time = Instant::now();
let start_time = SystemTime::now();
let running_time = Instant::now();
let slowkey = SlowKey::new(&slowkey_opts);

let handle = thread::spawn(move || {
Expand Down Expand Up @@ -563,8 +565,22 @@ fn main() {
}

println!(
"Finished in {}",
format_duration(Duration::new(start_time.elapsed().as_secs(), 0))
"Start time: {}",
DateTime::<Utc>::from(start_time)
.format("%Y-%m-%d %H:%M:%S")
.to_string()
.cyan()
);
println!(
"End time: {}",
DateTime::<Utc>::from(SystemTime::now())
.format("%Y-%m-%d %H:%M:%S")
.to_string()
.cyan()
);
println!(
"Total running time: {}",
format_duration(Duration::new(running_time.elapsed().as_secs(), 0))
.to_string()
.cyan()
);
Expand Down

0 comments on commit d914caa

Please sign in to comment.