Skip to content

Commit 7e35c68

Browse files
committed
Compatible with the output format of Cyan4973/xxHash
1 parent 59502b7 commit 7e35c68

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/calculator.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,10 @@ pub fn hash_calculator<R: BufRead>(
256256
}
257257

258258
match algorithm {
259-
SupportedAlgorithm::XXHASH32 => return Ok(format!("0x{:0>8x}", hasher.finish())),
260-
SupportedAlgorithm::XXHASH64 | SupportedAlgorithm::XXHASH3_64 => {
261-
return Ok(format!("0x{:0>16x}", hasher.finish()))
262-
}
263-
_ => Ok(format!("0x{:0>32x}", 0)), // Unreachable, wait for xxhash3_128.
259+
SupportedAlgorithm::XXHASH32 => return Ok(format!("{:0>8x}", hasher.finish())),
260+
SupportedAlgorithm::XXHASH64 => return Ok(format!("{:0>16x}", hasher.finish())),
261+
SupportedAlgorithm::XXHASH3_64 => return Ok(format!("XXH3_{:0>16x}", hasher.finish())),
262+
_ => Ok(format!("{:0>32x}", 0)), // Unreachable, wait for xxhash3_128.
264263
}
265264
} else {
266265
// hashes backend

src/extra.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ pub fn detect_hash_algorithm<S: AsRef<str>>(hash: S) -> Result<Vec<SupportedAlgo
5555
]),
5656
96 => Ok(vec![SupportedAlgorithm::SHA384]),
5757
128 => Ok(vec![SupportedAlgorithm::SHA512]),
58-
10 => Ok(vec![SupportedAlgorithm::XXHASH32]),
59-
18 => Ok(vec![
60-
SupportedAlgorithm::XXHASH64,
61-
SupportedAlgorithm::XXHASH3_64,
62-
]),
58+
8 => Ok(vec![SupportedAlgorithm::XXHASH32]),
59+
16 => Ok(vec![SupportedAlgorithm::XXHASH64]),
60+
21 => Ok(vec![SupportedAlgorithm::XXHASH3_64]),
6361
32 => Ok(vec![
6462
SupportedAlgorithm::MD5,
6563
SupportedAlgorithm::MD4,

0 commit comments

Comments
 (0)