feat(hash):基本完成图像感知散列功能。
This commit is contained in:
@@ -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<T: image::GenericImage<Pixel = image::Rgb<u8>>>(
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
pub extern crate image;
|
||||
|
||||
pub mod encryption;
|
||||
pub mod hash;
|
||||
pub mod serial_code;
|
||||
|
||||
Reference in New Issue
Block a user