fix(official): 修正官方 hash 校验算法

This commit is contained in:
2026-07-15 22:30:33 +08:00
parent 9e83bbea11
commit 60b8339ecb
3 changed files with 39 additions and 14 deletions
+10 -8
View File
@@ -1684,9 +1684,9 @@ fn xxhash32_round(acc: u32, input: u32) -> u32 {
fn xxhash32_avalanche(mut hash: u32) -> u32 {
hash ^= hash >> 15;
hash = hash.wrapping_mul(0x85EB_CA6B);
hash = hash.wrapping_mul(0x85EB_CA77);
hash ^= hash >> 13;
hash = hash.wrapping_mul(0xC2B2_AE35);
hash = hash.wrapping_mul(0xC2B2_AE3D);
hash ^= hash >> 16;
hash
}
@@ -2148,8 +2148,8 @@ exit 22
report.verified_hashes[0].algorithm,
OfficialResourceHashAlgorithm::XxHash32Decimal
);
assert_eq!(report.verified_hashes[0].expected, "3223500437");
assert_eq!(report.verified_hashes[0].actual, "3223500437");
assert_eq!(report.verified_hashes[0].expected, "2044170421");
assert_eq!(report.verified_hashes[0].actual, "2044170421");
let manifest = service.read_download_manifest().unwrap();
assert_eq!(manifest.version, DOWNLOAD_MANIFEST_VERSION);
@@ -2328,7 +2328,7 @@ exit 22
let bytes = if url.ends_with("/TableBundles/TableCatalog.bytes") {
b"ExcelDB.db".to_vec()
} else if url.ends_with("/TableBundles/TableCatalog.hash") {
b"3223500437".to_vec()
b"2044170421".to_vec()
} else if url.ends_with(".zip") {
one_file_zip(b"fixture.txt", b"ok")
} else {
@@ -2514,9 +2514,11 @@ exit 22
#[test]
fn verifies_known_real_seed_catalog_hash_samples() {
assert_eq!(xxhash32(b"ExcelDB.db"), 3223500437);
assert_eq!(xxhash32(b"FullPatch_000.zip"), 3628251239);
assert_eq!(xxhash32(b"JP_Airi_Win.zip"), 876690720);
assert_eq!(xxhash32(b""), 46947589);
assert_eq!(xxhash32(b"ExcelDB.db"), 2044170421);
assert_eq!(xxhash32(b"FullPatch_000.zip"), 4038880697);
assert_eq!(xxhash32(b"JP_Airi_Win.zip"), 1416778215);
assert_eq!(xxhash32(b"ExcelDB.db ExcelDB.db"), 2147704569);
}
#[test]
@@ -787,9 +787,9 @@ fn round(acc: u32, input: u32) -> u32 {
fn avalanche(mut hash: u32) -> u32 {
hash ^= hash >> 15;
hash = hash.wrapping_mul(0x85EB_CA6B);
hash = hash.wrapping_mul(0x85EB_CA77);
hash ^= hash >> 13;
hash = hash.wrapping_mul(0xC2B2_AE35);
hash = hash.wrapping_mul(0xC2B2_AE3D);
hash ^= hash >> 16;
hash
}