- else
- ircsnprintf(outbuf, HOSTLEN, "%X%X.%s",
- hosthash2, hosthash, ServerInfo.network_name);
+
+ *tptr++ = '\0';
+
+ snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
+}
+
+static void
+do_host_cloak_host(const char *inbuf, char *outbuf)
+{
+ char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
+ char *tptr;
+ unsigned int accum = get_string_weighted_entropy(inbuf);
+
+ strncpy(outbuf, inbuf, HOSTLEN);
+
+ /* pass 1: scramble first section of hostname using base26
+ * alphabet toasted against the weighted entropy of the string.
+ *
+ * numbers are not changed at this time, only letters.
+ */
+ for (tptr = outbuf; *tptr != '\0'; tptr++)
+ {
+ if (*tptr == '.')
+ break;
+
+ if (isdigit(*tptr) || *tptr == '-')
+ continue;
+
+ *tptr = b26_alphabet[(*tptr * accum) % 26];
+ }
+
+ /* pass 2: scramble each number in the address */
+ for (tptr = outbuf; *tptr != '\0'; tptr++)
+ {
+ if (isdigit(*tptr))
+ {
+ *tptr = 48 + ((*tptr * accum) % 10);
+ }
+ }