All pastes #98114 Raw Edit

Untitled

public c v1 · immutable
#98114 ·published 2006-07-24 10:50 UTC
rendered paste body
BYTE crypttab[256][256];void fBufferEncrypt_Sub1(void *thiz, BYTE flags, BYTE arg_4, BYTE *outbuf, WORD arg_C, WORD arg_10, WORD arg_14){	outbuf[7] = arg_0;	outbuf[6] = arg_4;	*(WORD*)(outbuf+0) = arg_C;	*(WORD*)(outbuf+2) = arg_10;	*(WORD*)(outbuf+4) = arg_14;	outbuf[9] = crypttab[crypttab[*(BYTE*)thiz][crypttab[outbuf[0]][outbuf[2]]]][crypttab[outbuf[6]][crypttab[outbuf[3]][outbuf[1]]]];	if(! (flags & 1))		return;	outbuf[7] = crypttab[outbuf[6]][outbuf[7]];	outbuf[0] = crypttab[outbuf[7] ^ *(BYTE*)thiz][outbuf[0]];	outbuf[1] = crypttab[outbuf[7] ^ outbuf[6]][outbuf[1]];	outbuf[2] = crypttab[outbuf[0] ^ outbuf[6]][outbuf[2]];	outbuf[3] = crypttab[outbuf[1] ^ *(BYTE*)thiz][outbuf[3]];	outbuf[4] = crypttab[outbuf[2] ^ *(BYTE*)thiz][outbuf[4]];	outbuf[5] = crypttab[outbuf[3] ^ outbuf[7]][outbuf[5]];}BYTE fBufferEncrypt_Sub2(void *thiz, BYTE flags, BYTE seed, BYTE *outbuf, BYTE *inbuf, int datalen, int padlen){	BYTE acc = 0;	int i, outlen = 10;		if(!(flags & 2)) {		memcpy(outbuf + 10, inbuf, datalen);		return 0;	}	for(i = 0; i < datalen; ++outlen, ++i) {		acc += inbuf[i];		outbuf[outlen] = crypttab[seed ^ (i & 0xFF)][inbuf[i]];	}	for(i = 0; i < padlen; ++outlen, ++i) {		outbuf[outlen] = crypttab[seed][outlen & 0xFF];	}	return acc;}int fBufferEncrypt(void *thiz, WORD arg_0, WORD arg_4, BYTE *inbuf, int datalen, BYTE *outbuf, int outlen, BYTE flags){	int padlen = 0, totallen;	BYTE tmp;		totallen = datalen + 10;	if(outlen < totallen)		return 0;	if(flags & 8)		*(BYTE*)thiz += 1;	tmp = rand() % 256;	if(flags & 4) {		if(outlen < totallen + tmp % 13) {			flags ^= 4;		} else {			totallen += tmp % 13;			padlen = tmp % 13;		}	}	fBufferEncrypt_Sub1(thiz=ebp, flags, tmp, outbuf, totallen, arg_0, arg_4);	tmp = fBufferEncrypt_Sub2(thiz=ebp, flags, arg_0 * tmp, outbuf, inbuf, datalen, padlen)	outbuf[8] = crypttab[crypttab[*(BYTE*)thiz][outbuf[6]]][tmp]	return totallen;}