Code:unsigned short table[] = { 0x0068, 0x0005, 0x0007, 0x8000, 0x0002, 0x0005, 0x0005, 0x0007, 0x000e, 0x0005, 0x000b, 0x0007, 0x8000, 0x0003, 0x8000, 0x003d, 0x00d7, 0x8000, 0x8000, 0x000a, 0x0006, 0x0009, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0025, 0x8000, 0x0005, 0x0004, 0x0008, 0x0013, 0x0008, 0x0003, 0x001a, 0x0007, 0x0014, 0x0005, 0x0002, 0x0005, 0x0001, 0x0005, 0x0002, 0x0002, 0x0011, 0x000f, 0x000a, 0x0005, 0x8000, 0x0002, 0x0002, 0x000a, 0x028d, 0x8000, 0x0008, 0x0007, 0x0009, 0x8000, 0x8000, 0x8000, 0x0002, 0x0025, 0x8000, 0x00c9, 0x8000, 0x8000, 0x0229, 0x02c9, 0x0005, 0x8000, 0x000b, 0x0049, 0x005d, 0x0005, 0x0009, 0x8000, 0x8000, 0x0006, 0x0002, 0x8000, 0x8000, 0x8000, 0x0002, 0x000c, 0x0001, 0x000b, 0x006e, 0x006a, 0x8000, 0x8000, 0x0004, 0x0002, 0x0049, 0x8000, 0x0031, 0x0005, 0x0009, 0x000f, 0x000d, 0x0001, 0x0004, 0x8000, 0x0015, 0x8000, 0x8000, 0x0003, 0x0009, 0x0013, 0x0003, 0x000e, 0x8000, 0x001c, 0x8000, 0x0005, 0x0002, 0x8000, 0x0023, 0x0010, 0x0011, 0x8000, 0x0009, 0x8000, 0x0002, 0x8000, 0x000d, 0x0002, 0x8000, 0x003e, 0x8000, 0x0002, 0x0027, 0x0045, 0x0002, 0x8000, 0x8000, 0x0042, 0x8000, 0x8000, 0x8000, 0x000b, 0x8000, 0x8000, 0x8000, 0x0013, 0x0041, 0x8000, 0x0063, 0x8000, 0x0009, 0x8000, 0x0002, 0x8000, 0x001a, 0x8000, 0x0102, 0x0135, 0x0033, 0x8000, 0x8000, 0x0003, 0x0009, 0x0009, 0x0009, 0x0095, 0x8000, 0x8000, 0x0004, 0x8000, 0x8000, 0x0005, 0x8000, 0x8000, 0x8000, 0x8000, 0x000d, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0040, 0x0009, 0x8000, 0x8000, 0x0003, 0x0006, 0x0009, 0x0003, 0x8000, 0x8000, 0x8000, 0x0024, 0x8000, 0x8000, 0x8000, 0x0006, 0x00cb, 0x0001, 0x0031, 0x0002, 0x0006, 0x0006, 0x0007, 0x8000, 0x0001, 0x8000, 0x004e, 0x8000, 0x0002, 0x0019, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x010c, 0x8000, 0x8000, 0x0009, 0x8000 }; struct { unsigned int e1; unsigned int e2; unsigned int e3; unsigned int e4; } enco; void enccalc(unsigned int ip) { unsigned int pi = ~ip; enco.e1 = ((pi ^ 0x1357) << 16) | ((ip ^ 0xaaaa) & 0x0000); enco.e2 = ((ip ^ 0x4321) >> 16) | ((pi ^ 0xabcd) & 0xffff); enco.e3 = (((ip ^ pi) & 0x0f0f) ^ ip) ^ 0xa76e; enco.e4 = (((ip ^ pi) & 0x0f0f) ^ pi) ^ 0xf4bc; } unsigned short pcklength(unsigned char *data) { if(*data < 222) { return(table[*data]); } return(0); } void cryptin(unsigned char *data, int len) { unsigned int t1, t2; for(; len--; data++) { *data ^= enco.e1; t1 = enco.e1; t2 = enco.e2; enco.e1 = ((t1 >> 1) | (t2 << 31)) ^ 0x7e7f; t2 = ((t2 >> 1) | (t1 << 31)) ^ 0xa7ec; enco.e2 = ((t2 >> 1) | (t1 << 31)) ^ 0xa7ed; } } int logbuild(unsigned char *buff, unsigned char *come, unsigned char *doit) { int len; buff[0] = 0x80; strncpy(buff + 1, come, 30); strncpy(buff + 1 + 30, doit, 31); len = pcklength(buff); cryptin(buff, len); return(len); }