Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions codegenerator/cli/src/persisted_state/hash_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ impl HashString {
pub fn from_string(string: String) -> Self {
let mut hasher = Sha256::new();
hasher.update(string);
let hash = hasher.finalize().to_vec();
HashString(format!("{:?}", hash))
let hash = hasher.finalize();
// Use hexadecimal encoding to match other hash functions
HashString(format!("{:x}", hash))
}

#[cfg(test)]
Expand Down Expand Up @@ -107,6 +108,15 @@ mod test {
);
}

#[test]
fn string_hash() {
let hash = HashString::from_string("config".to_string());
assert_eq!(
hash.inner(),
"b79606fb3afea5bd1609ed40b622142f1c98125abcfe89a76a661b0e8e343910".to_string()
);
}

#[test]
#[should_panic]
fn fail_hash_empty_fail() {
Expand Down