From e972998e09940ccbe309edff433b0bbce7cf53e1 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Fri, 7 Oct 2022 23:05:32 +0800 Subject: [PATCH] feat: add highwayhash --- __crypto/highwayhash/Cargo.lock | 16 ++++++++++++++++ __crypto/highwayhash/Cargo.toml | 10 ++++++++++ __crypto/highwayhash/README.md | 5 +++++ __crypto/highwayhash/src/main.rs | 12 ++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 __crypto/highwayhash/Cargo.lock create mode 100644 __crypto/highwayhash/Cargo.toml create mode 100644 __crypto/highwayhash/README.md create mode 100644 __crypto/highwayhash/src/main.rs diff --git a/__crypto/highwayhash/Cargo.lock b/__crypto/highwayhash/Cargo.lock new file mode 100644 index 0000000..13472f9 --- /dev/null +++ b/__crypto/highwayhash/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "highway" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3688f13e7735ae5ca93edc490f6c5885b77d473255bc1fed92b9c805f972bf94" + +[[package]] +name = "highwayhash" +version = "0.1.0" +dependencies = [ + "highway", +] diff --git a/__crypto/highwayhash/Cargo.toml b/__crypto/highwayhash/Cargo.toml new file mode 100644 index 0000000..cf9fd23 --- /dev/null +++ b/__crypto/highwayhash/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "highwayhash" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +highway = "0.8.0" + diff --git a/__crypto/highwayhash/README.md b/__crypto/highwayhash/README.md new file mode 100644 index 0000000..8ee9f51 --- /dev/null +++ b/__crypto/highwayhash/README.md @@ -0,0 +1,5 @@ + + +* https://github.com/nickbabcock/highway-rs +* https://github.com/rurban/smhasher + diff --git a/__crypto/highwayhash/src/main.rs b/__crypto/highwayhash/src/main.rs new file mode 100644 index 0000000..c1e51f0 --- /dev/null +++ b/__crypto/highwayhash/src/main.rs @@ -0,0 +1,12 @@ +use highway::{HighwayHash, HighwayHasher, Key}; + +fn main() { + let res = HighwayHasher::default().hash256("hello world".as_bytes()); + println!("{:x?}", res); + let res = HighwayHasher::default().hash256(&[0xff]); + println!("{:x?}", res); + let mut hasher256 = HighwayHasher::new(Key([1, 2, 3, 4])); + hasher256.append(&[0xff]); + let res: [u64; 4] = hasher256.finalize256(); + println!("{:x?}", res); +}