Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Translate this code

$
0
0

Does anybody translate this code to vb.net or c#?(better if is vb.net)

// thanks to cryptic for help ^^
int decryptnosfile(unsigned char *cData, unsigned int f_buffer, unsigned char *cOut, unsigned int &nOut)
		{
		 static unsigned char table[] = { 0, 0x20,'-','.','0','1','2','3','4','5','6','7','8','9', 0x0d };

		 unsigned int i, offset, len;

		 unsigned char size, c;

		 len = f_buffer;

		 unsigned char *cBuffer;
		 cBuffer = (unsigned char*)malloc(f_buffer + 1);
		 memcpy(cBuffer, cData, f_buffer);

		 offset = nOut = 0;
 
		 while(offset < len
		 {
		 if(cBuffer[offset] == 0xFFu)
		 {
		 offset++;
		 *(cOut + nOut++) = 0x0d;
		 continue;
		 }

		 size = cBuffer[offset++];

		 i = 0;
		 if ((size & 0x80U) == 0) 
		 {
		 while ((i++ < size) && (offset < len))
		 {
		 *(cOut + nOut++) = (cBuffer[offset++] ^ 0x33U);
		 }
		 }
		 else
		 {
		 size &= 0x7FU;
		 while ((i < size) && (offset < len))
		 {
		 c = cBuffer[offset++];
		 *(cOut + nOut++) = (table[(c & 0xF0U) >> 4]);
		 if (table[c & 0x0FU] != 0)
		 *(cOut + nOut++) = table[c & 0x0FU];
		 i += 2;
		 }
		 }
		 }

		 free(cBuffer);
		 return offset;
		}


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>