-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update hasher registry to work with Maven central and add MD5 hash
- Loading branch information
1 parent
97a7447
commit 71cd379
Showing
8 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::Result; | ||
use md5::{Digest, Md5}; | ||
|
||
/// Hashes the data using MD5. | ||
/// | ||
/// # Errors | ||
/// * If the data cannot be hashed. | ||
pub fn hash(data: &Vec<u8>) -> Result<String> { | ||
let mut hasher = Md5::new(); | ||
hasher.update(data); | ||
let hash = hex::encode(hasher.finalize()); | ||
Ok(hash) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_hash() -> Result<()> { | ||
let data = vec![4, 2]; | ||
let hash = hash(&data)?; | ||
assert_eq!("21fb3d1d1a91a7e80dff456205f3380b", hash); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod blake2b_512; | ||
pub mod blake2s_256; | ||
pub mod md5; | ||
pub mod registry; | ||
pub mod sha1; | ||
pub mod sha2_256; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub(crate) mod models; | ||
pub mod repository; | ||
|
||
pub const URL: &str = "https://repo1.maven.org/maven2"; |