File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 1818
1919// Simple placeholder hash function (not cryptographic, just consistent)
2020void fossil_jellyfish_hash (const char * input , const char * output , uint8_t * hash_out ) {
21- size_t len = strlen (input ) + strlen (output );
21+ // Enhanced: Use a simple FNV-1a-like mixing over input and output
22+ const uint32_t FNV_PRIME = 0x01000193 ;
23+ uint32_t hash = 0x811c9dc5 ;
24+ size_t in_len = strlen (input );
25+ size_t out_len = strlen (output );
26+
27+ // Mix input
28+ for (size_t i = 0 ; i < in_len ; ++ i ) {
29+ hash ^= (uint8_t )input [i ];
30+ hash *= FNV_PRIME ;
31+ }
32+ // Mix output
33+ for (size_t i = 0 ; i < out_len ; ++ i ) {
34+ hash ^= (uint8_t )output [i ];
35+ hash *= FNV_PRIME ;
36+ }
37+
38+ // Spread hash into hash_out buffer
2239 for (size_t i = 0 ; i < FOSSIL_JELLYFISH_HASH_SIZE ; ++ i ) {
23- hash_out [i ] = (uint8_t )((input [i % strlen (input )] ^ output [i % strlen (output )] ^ (int )i ) + i * 31 );
40+ hash ^= (hash >> 13 );
41+ hash *= FNV_PRIME ;
42+ hash_out [i ] = (uint8_t )((hash >> (8 * (i % 4 ))) & 0xFF );
2443 }
2544}
2645
You can’t perform that action at this time.
0 commit comments