Skip to content

Commit

Permalink
Fix sha-1 usage and clippy+fmt complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
brycx committed Aug 8, 2020
1 parent 23c077b commit 2ac2d61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ pub fn read_file(path: &str) -> Result<BufReader<File>, Error> {
/// Return SHA1 digest of string.
pub fn hash_password(password: &str) -> String {
let mut sha_digest = Sha1::default();
sha_digest.input(password.as_bytes());
sha_digest.update(password.as_bytes());
// Make uppercase for easier comparison with
// HIBP API response
hex::encode(sha_digest.result()).to_uppercase()
hex::encode(sha_digest.finalize()).to_uppercase()
}

/// Strip all whitespace and all newlines from a given string.
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Config {
dir.push(CHECKPWN_CONFIG_DIR);
dir.push(CHECKPWN_CONFIG_FILE_NAME);
Some(ConfigPaths {
config_file_path: dir.to_path_buf(),
config_file_path: dir,
})
}
None => None,
Expand All @@ -55,7 +55,7 @@ impl Config {
Ok(api_key) => {
self.api_key = api_key;
Ok(())
},
}
Err(std::env::VarError::NotPresent) => {
let path = self
.get_config_path()
Expand All @@ -81,7 +81,7 @@ impl Config {
self.api_key = config_yml.api_key;
}

pub fn save_config(&self, api_key: &String) -> Result<(), Box<dyn std::error::Error>> {
pub fn save_config(&self, api_key: &str) -> Result<(), Box<dyn std::error::Error>> {
let path: ConfigPaths = self
.get_config_path()
.expect("Failed to determine configuration file path.");
Expand Down

0 comments on commit 2ac2d61

Please sign in to comment.