💾 Archived View for gmi.noulin.net › gitRepositories › hashfunctions › file › main.c.gmi captured on 2023-07-10 at 15:55:00. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
main.c (1122B)
1 #! /usr/bin/env sheepy 2 /* or direct path to sheepy: #! /usr/local/bin/sheepy */ 3 4 #include "libsheepyObject.h" 5 #include "hashfunctions.h" 6 7 int argc; char **argv; 8 9 int main(int ARGC, char** ARGV) { 10 11 argc = ARGC; argv = ARGV; 12 13 initLibsheepy(argv[0]); 14 setLogMode(LOG_PROG); 15 16 17 // siphash seed setup 18 19 u8 hash_function_seed[16]; 20 setSoftwareRandom(); 21 range(i, COUNT_ELEMENTS(hash_function_seed)) { 22 hash_function_seed[i] = randomChoice(256); 23 } 24 25 // compute some hash 26 // 27 logVarG(u32Hash(3)); 28 logVarG(u64Hash(3)); 29 30 // 32bit string hash 31 logVarG(strHashFNV1A("the key")); 32 33 // 64bit string hash 34 logVarG(strHashFNV1A64("the key")); 35 36 // siphash 37 38 logVarG(siphash("the key",strlen("the key"),hash_function_seed)); 39 40 // murmur2 41 42 logVarG(murmur2hash("the key", strlen("the key"))); 43 44 // murmur3 45 46 u32 seed = 2506631878; 47 u64 hash[2]; 48 murmurHash3_x64_128("the key", strlen("the key"), seed, hash); 49 logI("murmurHash3_x64_128: %lu %lu", hash[0], hash[1]); 50 51 // jump consistent hash 52 i32 jumpHash = jumpConsistentHash(10863919174838991 /* key */, 11 /* bucket count */); 53 54 logVarG(jumpHash); 55 }