From i6t4 at jupiter.sun.csd.unb.ca Wed Jul 7 22:04:10 1993 From: i6t4 at jupiter.sun.csd.unb.ca (Nickey MacDonald) Date: Wed, 7 Jul 93 22:04:10 PDT Subject: Some source code for phone number coding... Message-ID: Here is a couple of message about my phone encoding format (giving progressively more info to a person trying to guess the format) followed by the complete source... Use it well. (TABsize was 3.) Okay, well without giving you the source... heres the biggest hint I can think of... >From /etc/magic: 0 string \037\235 compressed data Translating that to decimal and in 4 byte unsigned long we get (\037\235\0\0 == 31,157,0,0 == 0,530,382,848 ^^^^^ >From the start of my posted list of phone numbers: (503) 241-9796 ext: 09 ^^^ ^ ?? ? If you know the rules for forming (valid looking) phone numbers... Anyway, to finially give the whole thing away... The file that is hidden starts with these 4 bytes... 1f 9d 90 54 == 0,530,419,796 Well.. I like puzzles... (as long as the answer is eventually revealed) so I'll let you think it over for a bit, before I send you the source... ;-) Okay well... lets assume that all valid phone numbers must be in the form [2-9][0-1][0-9] [2-9][0-9][0-9] [0-9][0-9][0-9][0-9] This is the form of my encoding... now if you take a sample number, like 1,234,567,890 and try encode it into a phone number, you would get (123) 456-7890 ^^ And you notice that the 1 and the two are out of range... Well.. as it happens, for 32 bit unsigned numbers the range is 0 to 4,294,967,294... The first digit will always be 0-4, half of which are illegal in that position, so I decided to swap the first two digits... That doesn't fix all of the range problems, thus whenever there is an invalid digit in position 1,2 or 4 I move it to the extension and put a special indicator value (the higest of the legal range) in its place. Thats the whole secret... Code will follow soon... :-) /* pe.c phone encode Written by: Nickey MacDonald July 7, 1993 Encode a message as a list of phone numbers... There are some tricks used to make the phone numbers appear more realistic, and there is a caveate... If the input file has 4 null bytes aligned of a 4 byte boundry, then the program will think its the EOF and stop... This could be fixed easily... I just didn't. */ #include unsigned long getbytes(FILE *fp); int main(void) { unsigned short i, ei; /* i=work counter, ei=ext. counter */ unsigned char pn[10], ext[4], v=0; /* Digits of phone num, ext and a */ /* pseudo random value */ unsigned long b; /* 4 bytes compress to a unsigned long */ char tpnumbuf[11]; /* a sprinft buffer for b */ /* Read until EOF or 4 properly aligned null bytes */ while((b=getbytes(stdin)) != 0) { ei=0; /* Convert the unsigned long into a string */ sprintf(tpnumbuf, "%010lu", b); /* Pick up the digits of the unsigned long */ /* Because of the distribution, swap the first two digits... */ pn[0]=tpnumbuf[1]-'0'; pn[1]=tpnumbuf[0]-'0'; for(i=2; i<10; i++) { pn[i]=tpnumbuf[i]-'0'; v+=pn[i]; } /* The first digit of the area code must be [2-9] */ if (pn[0]<3) { ext[ei++]=pn[0]; pn[0]=2; } /* Currently the middle digit of area code must be 0 or 1 */ if (pn[1]>0) { ext[ei++]=pn[1]; pn[1]=1; } /* The first digit of prefix must be [2-9] */ if (pn[3]<3) { ext[ei++]=pn[3]; pn[3]=2; } /* Generate the output phone number */ fprintf(stdout, "(%d%d%d) %d%d%d-%d%d%d%d", pn[0], pn[1], pn[2], pn[3], pn[4], pn[5], pn[6], pn[7], pn[8], pn[9]); /* Generate the extension if needed */ if (ei>0) { ext[ei++]=v%10; fprintf(stdout, " ext: "); for (i=0; i