From 7bd18b4b22f3a6bf86b131329345f9a75d8f699c Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 28 Aug 2021 09:45:57 -0400 Subject: Commit Rust POC This replaces the Python script. Since all MIT-licensed code is removed, the LICENSE file is as well. 'cargo run' to run the program. Signed-off-by: Malfurious --- src/demo_hash.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/demo_hash.rs (limited to 'src/demo_hash.rs') diff --git a/src/demo_hash.rs b/src/demo_hash.rs new file mode 100644 index 0000000..115a10f --- /dev/null +++ b/src/demo_hash.rs @@ -0,0 +1,23 @@ +use sha2::Digest; + +pub fn hash_bigint(n: usize, i: &num::BigInt) -> Vec +{ + let (_, bytes) = i.to_bytes_be(); + assert!(bytes.len() <= n); + + let mut hash = sha2::Sha512::new(); + hash.input(vec![0; n - bytes.len()]); + hash.input(bytes); + + hash.result().to_vec() +} + +pub fn show_hash(h: &Vec) +{ + for x in h + { + print!("{:02x}", x); + } + + println!(); +} -- cgit v1.2.3