Skip to content

Commit

Permalink
Switch out the tiny_keccak hashing library for the sha3 library (#894)
Browse files Browse the repository at this point in the history
The sha3 library seems more widely used and actively maintained.

All we do with these hashes is save the hash in the output file and
compare to determine if we need a rebuild.
  • Loading branch information
dburgener committed May 8, 2024
1 parent f1060df commit 1eb87a0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 15 deletions.
84 changes: 74 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lalrpop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ itertools = { version = "0.11", default-features = false, features = ["use_std"]
petgraph = { version = "0.6", default-features = false }
regex = { workspace = true }
regex-syntax = { workspace = true }
sha3 = { version = "0.10", default-features = false }
string_cache = { version = "0.8", default-features = false }
term = { version = "0.7", default-features = false }
tiny-keccak = { version = "2.0.2", features = ["sha3"] }
unicode-xid = { version = "0.2", default-features = false }
walkdir = "2.4.0"

Expand Down
7 changes: 3 additions & 4 deletions lalrpop/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::tok;
use crate::util::Sep;
use itertools::Itertools;
use lalrpop_util::ParseError;
use tiny_keccak::{Hasher, Sha3};
use sha3::{Digest, Sha3_256};
use walkdir::WalkDir;

use std::ffi::OsStr;
Expand Down Expand Up @@ -44,11 +44,10 @@ fn hash_file(file: &Path) -> io::Result<String> {
let mut file_bytes = Vec::new();
file.read_to_end(&mut file_bytes).unwrap();

let mut sha3 = Sha3::v256();
let mut sha3 = Sha3_256::new();
sha3.update(&file_bytes);

let mut output = [0u8; 32];
sha3.finalize(&mut output);
let output = sha3.finalize();

Ok(format!("// sha3: {:02x}", output.iter().format("")))
}
Expand Down

0 comments on commit 1eb87a0

Please sign in to comment.