diff --git a/Cargo.lock b/Cargo.lock index 0039421..9bea084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,7 +274,7 @@ dependencies = [ [[package]] name = "rustgenpass" -version = "0.1.0" +version = "0.2.0" dependencies = [ "base64", "clap", diff --git a/Cargo.toml b/Cargo.toml index 085a766..dcadab0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "rustgenpass" authors = ["Olle Wreede "] description = "Generate a hashed password similar to SuperGenPass." -version = "0.1.0" +version = "0.2.0" edition = "2021" [dependencies] @@ -12,7 +12,7 @@ lazy_static = "1.4" md-5 = "0.10" regex = "1.6" rpassword = "7.0.0" -sha2 = "0.10.6" +sha2 = "0.10" [[bin]] name = "rgp" diff --git a/README.md b/README.md index 03c9120..0ee62fc 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,23 @@ Usage ----- ``` -rustgenpass 0.1.0 +rustgenpass 0.2.0 Generate a hashed password similar to SuperGenPass. USAGE: rgp [OPTIONS] --domain OPTIONS: - -d, --domain Domain / URL + -d, --domain Domain / URL to generate password for -h, --help Print help information + -H, --hash Hashing method to use [default: md5] [possible values: md5, sha512] -k, --keep-subdomains Don't remove subdomains from domain - -l, --length Length of password, min: 4, max: 24 [default: 10] + -l, --length Length of generated password, min: 4, max: 24 [default: 10] -p, --password Master password, if not given, reads from stdin -P, --passthrough Passthrough domain unmodified to hash function -r, --rounds Number of hash rounds [default: 10] -s, --secret Secret added to the master password - -V, --version Print version information + -V, --version Print version informationrustgenpass 0.2.0 ``` License diff --git a/src/lib.rs b/src/lib.rs index 3214082..95f17b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,21 +131,21 @@ fn validate_password>(password: S) -> bool { && RE_CONTAINS_UPPERCASE_LETTER.is_match(password.as_ref()) } -fn b64_md5>(hash: S) -> String { +fn base64_md5>(hash: S) -> String { let mut hasher = Md5::new(); hasher.update(hash.as_ref()); let digest = hasher.finalize(); - base64encode(&digest) + base64_encode(&digest) } -fn b64_sha512>(hash: S) -> String { +fn base64_sha512>(hash: S) -> String { let mut hasher = Sha512::new(); hasher.update(hash.as_ref()); let digest = hasher.finalize(); - base64encode(&digest) + base64_encode(&digest) } -fn base64encode(digest: &[u8]) -> String { +fn base64_encode(digest: &[u8]) -> String { let b64_md5 = base64::encode(digest); b64_md5 .chars() @@ -215,8 +215,8 @@ pub fn generate_with_config>( let mut i = 0; while i < hash_rounds || !validate_password(&hash[..length]) { hash = match hash_algorithm { - HashAlgorithm::MD5 => b64_md5(hash), - HashAlgorithm::SHA512 => b64_sha512(hash), + HashAlgorithm::MD5 => base64_md5(hash), + HashAlgorithm::SHA512 => base64_sha512(hash), }; i += 1; } diff --git a/src/main.rs b/src/main.rs index 20d4771..1a0b59b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,6 @@ use clap::Parser; use rustgenpass::{generate_with_config, get_hostname, Cli}; fn main() -> Result<(), String> { - /* TODO: - * Support sha512 hashing - * Builder interface for library - */ let cli = Cli::parse(); let password = cli.password.unwrap_or_else(|| { rpassword::prompt_password("Enter master password: ").expect("You must enter a password.")