Files
wheel_rfm69_counter/radio_code/rfm69_gateway/test_hash.c
T
2026-08-31 22:43:51 -04:00

21 lines
393 B
C

#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
uint32_t hash_me(const char* str) {
uint32_t hash = 0; // Start with a 32-bit hash (we'll constrain to 24 bits)
while (*str) {
hash = (hash * 31 + (uint8_t)(*str)) % 0xFFFFFF;
str++;
}
return hash;
}
void main()
{
uint32_t hash_result= hash_me("Hello World");
printf("%"PRIu32"\n", hash_result);
}