View Single Post
Old 14.03.2006, 18:12   #3
aralyon
Архивный участник
 
Join Date: Sep 2005
Posts: 72
Default

I'm using this java code (extracted from l2j and compiled under .net as J#)
Code:
public long decrypt(ubyte[] raw)
	{
		if (_key == null)
		{
			return 0;
		}

		int temp = 0;
		int j = 0;
		for (int i = 0; i < raw.length; i++)
		{
			int temp2 = raw[i] & 0xff;
			raw[i] = (ubyte)(temp2 ^ (_key[j++] & 0xff) ^ temp);
			temp = temp2;
			if (j > 7)
			{
				j = 0;
			}
		}

		long old = _key[0] & 0xff;
		old |= _key[1] << 8 & 0xff00;
		old |= _key[2] << 0x10 & 0xff0000;
		old |= _key[3] << 0x18 & 0xff000000;

		old += raw.length;

		_key[0] = (ubyte)(old & 0xff);
		_key[1] = (ubyte)(old >> 0x08 & 0xff);
		_key[2] = (ubyte)(old >> 0x10 & 0xff);
		_key[3] = (ubyte)(old >> 0x18 & 0xff);

		return 1;
	}
It looks same as that C++ code :?
As I wrote, it's ok with l2j, but there are some bad bytes (just some, most are ok) if I use it with normal server
aralyon is offline