哪位高手帮忙把C翻译成delphi,多谢int qqdecrypt( unsigned char* instr, int instrlen, unsigned char* key,
unsigned char*  outstr, int* outstrlen_ptr)
{
unsigned char 
decrypted[8], m[8],
* crypt_buff, 
* crypt_buff_pre_8, 
* outp;
int 
count, 
context_start, 
pos_in_byte, 
padding;#define decrypt_every_8_byte()  {\
char bNeedRet = 0;\
for (pos_in_byte = 0; pos_in_byte < 8; pos_in_byte ++ ) {\
if (context_start + pos_in_byte >= instrlen) \
{\
bNeedRet = 1;\
break;\
}\
decrypted[pos_in_byte] ^= crypt_buff[pos_in_byte];\
}\
if( !bNeedRet ) { \
decipher( (unsigned int *) decrypted, \
(unsigned int *) key, \
(unsigned int *) decrypted);\
\
context_start +=  8;\
crypt_buff    +=  8;\
pos_in_byte   =   0;\
}\
}/* decrypt_every_8_byte*/ /* at least 16 bytes and %8 == 0*/
if ((instrlen % 8) || (instrlen < 16)) return 0; 
/* get information from header*/
decipher( (unsigned int *) instr, 
(unsigned int *) key, 
(unsigned int *) decrypted);
pos_in_byte = decrypted[0] & 0x7;
count = instrlen - pos_in_byte - 10; /* this is the plaintext length*/
/* return if outstr buffer is not large enought or error plaintext length*/
if (*outstrlen_ptr < count || count < 0) return 0; memset(m, 0, 8);
crypt_buff_pre_8 = m;
*outstrlen_ptr = count;   /* everything is ok! set return string length*/ crypt_buff = instr + 8;   /* address of real data start */
context_start = 8;        /* context is at the second 8 byte*/
pos_in_byte ++;           /* start of paddng stuffv*/ padding = 1;              /* at least one in header*/
while (padding <= 2) {    /* there are 2 byte padding stuff in header*/
if (pos_in_byte < 8) {  /* bypass the padding stuff, none sense data*/
pos_in_byte ++; padding ++;
}
if (pos_in_byte == 8) {
crypt_buff_pre_8 = instr;
//if (! decrypt_every_8_byte()) return 0; 
decrypt_every_8_byte();
}
}/* while*/ outp = outstr;
while(count !=0) {
if (pos_in_byte < 8) {
*outp = crypt_buff_pre_8[pos_in_byte] ^ decrypted[pos_in_byte];
outp ++;
count --;
pos_in_byte ++;
}
if (pos_in_byte == 8) {
crypt_buff_pre_8 = crypt_buff - 8;
//if (! decrypt_every_8_byte()) return 0;
decrypt_every_8_byte();
}
}/* while*/
for (padding = 1; padding < 8; padding ++) {
if (pos_in_byte < 8) {
if (crypt_buff_pre_8[pos_in_byte] ^ decrypted[pos_in_byte]) {
return 0;
}
pos_in_byte ++; 
}
if (pos_in_byte == 8 ) {
crypt_buff_pre_8 = crypt_buff;
//if (! decrypt_every_8_byte()) return 0; 
decrypt_every_8_byte();
}
}/* for*/
return 1;}