/*** XOR_STR. Exclusive-or an unsigned 4 byte number with a string. / / num = xor_str (num, str); / / Parameters: / / Purpose: / / How it works: / / Returns: / / Error Conditions: / / Home: xorstr.c / */ /*** Copyleft 1999 Caucus Systems Inc. CPW2 is "Open Source". */ /*: CR 10/15/97 17:40 New function. */ /*: CR 5/27/99 12:24 Updated to copyleft license. */ #define FUNCTION typedef unsigned int uint4; /* 4 byte unsigned integer on this platform */ FUNCTION uint4 xor_str (uint4 num, char *str) { union { uint4 num; char str[4]; } map; char *p; int i; map.num = 0; for (i=0, p=str; *p && i<4; ++i, ++p) map.str[i] = *p; return (num ^ map.num); }