Managed to generate a first secret
This commit is contained in:
parent
1a56ee42de
commit
96656afdae
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -19,6 +19,12 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base32"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@ -260,6 +266,7 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
|||||||
name = "totp_generator"
|
name = "totp_generator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base32",
|
||||||
"base64",
|
"base64",
|
||||||
"clap",
|
"clap",
|
||||||
"totp_rfc6238",
|
"totp_rfc6238",
|
||||||
|
@ -8,4 +8,5 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
totp_rfc6238 = "0.5.0"
|
totp_rfc6238 = "0.5.0"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
|
base32 = "0.4.0"
|
||||||
clap = { version = "3.1.6", features = ["derive"] }
|
clap = { version = "3.1.6", features = ["derive"] }
|
@ -1,3 +1,4 @@
|
|||||||
|
use base32::Alphabet;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use totp_rfc6238::{HashAlgorithm, TotpGenerator};
|
use totp_rfc6238::{HashAlgorithm, TotpGenerator};
|
||||||
|
|
||||||
@ -27,8 +28,11 @@ fn main() {
|
|||||||
.set_hash_algorithm(HashAlgorithm::SHA1)
|
.set_hash_algorithm(HashAlgorithm::SHA1)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let key = base64::decode(args.secret).unwrap();
|
let key = base32::decode(
|
||||||
|
Alphabet::RFC4648 { padding: true },
|
||||||
|
&args.secret,
|
||||||
|
).unwrap();
|
||||||
let code = totp_generator.get_code(&key);
|
let code = totp_generator.get_code(&key);
|
||||||
|
|
||||||
println!("Secret len = {}", code);
|
println!("Secret = {}", code);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user