-
-
Save robacarp/5293806 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
short passcode(const char *callsign) { | |
uint8_t i, len; | |
short hash = KEY; | |
char no_ssid[10], *p1 = no_ssid, *ptr = no_ssid; | |
// remove SSID | |
while((*callsign != '-') && (*callsign != '\0')) *p1++ = toupper((int) (*callsign++)); | |
*p1 = '\0'; | |
i = 0; | |
len = strlen(no_ssid); | |
while(i < len) { | |
hash ^= (unsigned char) (*ptr++) << 8; // high byte | |
hash ^= (*ptr++); // lower byte | |
i+=2; | |
} | |
return (short) (hash & 0x7fff); // force positive value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment