generalize hash() function

This commit is contained in:
cyberman54 2020-12-27 00:36:23 +01:00
parent 9dc8e43f90
commit a4daa772c3
3 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,6 @@
#include <Arduino.h> #include <Arduino.h>
#include <inttypes.h> #include <inttypes.h>
uint32_t IRAM_ATTR rokkit(const char *data, int len); uint32_t IRAM_ATTR hash(const char *data, int len);
#endif #endif

View File

@ -85,3 +85,7 @@ uint32_t IRAM_ATTR rokkit(const char *data, int len) {
return hash; return hash;
} }
uint32_t IRAM_ATTR hash(const char *data, int len) {
return rokkit(data, len);
}

View File

@ -141,7 +141,7 @@ uint16_t mac_analyze(MacBuffer_t MacBuffer) {
snprintf(buff, sizeof(buff), "%08X", snprintf(buff, sizeof(buff), "%08X",
*mac + (uint32_t)salt); // convert unsigned 32-bit salted MAC *mac + (uint32_t)salt); // convert unsigned 32-bit salted MAC
// to 8 digit hex string // to 8 digit hex string
uint16_t hashedmac = rokkit(&buff[3], 5); // hash MAC 8 digit -> 5 digit uint16_t hashedmac = hash(&buff[3], 5); // hash MAC 8 digit -> 5 digit
auto newmac = macs.insert(hashedmac); // add hashed MAC, if new unique auto newmac = macs.insert(hashedmac); // add hashed MAC, if new unique
bool added = bool added =
newmac.second ? true : false; // true if hashed MAC is unique in container newmac.second ? true : false; // true if hashed MAC is unique in container