MCPcopy Create free account
hub / github.com/Tracktion/choc / demonstrateHashConsistency

Function demonstrateHashConsistency

examples/xxhash_example.cpp:51–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void demonstrateHashConsistency()
52{
53 std::cout << "\n=== Hash Consistency Demo ===\n\n";
54
55 std::string testData = "Consistency test string";
56 uint32_t seed = 12345;
57
58 std::cout << "Testing that identical inputs produce identical hashes:\n";
59
60 // Hash the same data multiple times
61 for (int i = 0; i < 3; ++i)
62 {
63 choc::hash::xxHash32 hasher32 (seed);
64 hasher32.addInput (testData.data(), testData.length());
65 uint32_t hash32 = hasher32.getHash();
66
67 choc::hash::xxHash64 hasher64 (seed);
68 hasher64.addInput (testData.data(), testData.length());
69 uint64_t hash64 = hasher64.getHash();
70
71 std::cout << "Run " << (i + 1) << ": 32-bit=0x" << std::hex << hash32
72 << ", 64-bit=0x" << hash64 << std::dec << "\n";
73 }
74}
75
76void demonstrateSeedVariation()
77{

Callers 1

mainFunction · 0.85

Calls 4

addInputMethod · 0.80
getHashMethod · 0.80
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected