diff --git a/Cargo.toml b/Cargo.toml index 10f8fc7..59dc1d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,12 @@ crate-type = ["dylib", "rlib"] [dependencies] aes = "0.8.3" base64 = "0.21.2" +blockhash = "0.5.0" cbc = "0.1.2" des = "0.8.1" hex = "0.4.3" hmac-sha512 = "1.1.5" +image = "0.24.6" md-5 = "0.10.5" rand = "0.8.5" sha1 = "0.10.5" diff --git a/src/hash/mod.rs b/src/hash/mod.rs index 69fb356..3c090c1 100644 --- a/src/hash/mod.rs +++ b/src/hash/mod.rs @@ -26,3 +26,24 @@ pub mod sha512 { crate::serialize::to_hex(result.as_slice()) } } + +pub mod image_hash { + pub enum Precision { + Low = 2, + Medium = 8, + High = 18, + Detailed = 32, + } + + pub fn hash_image>>( + input: &T, + precision: Precision, + ) -> String { + match precision { + Precision::Low => blockhash::blockhash16(input).to_string(), + Precision::Medium => blockhash::blockhash64(input).to_string(), + Precision::High => blockhash::blockhash144(input).to_string(), + Precision::Detailed => blockhash::blockhash256(input).to_string(), + } + } +} diff --git a/src/lib.rs b/src/lib.rs index d85ad96..b637022 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +pub extern crate image; + pub mod encryption; pub mod hash; pub mod serial_code;