def WorldEncrypt(packet): return Utils._Pack(packet, _ENCRYPTION_TABLE)
def WorldDecrypt(packet, session, is_first_packet = False): xored = _WorldXor(packet, session, is_first_packet) return Utils._Unpack(xored, _DECRYPTION_TABLE)
def test_real_client_pack2(self): self.assertEqual(Utils._Pack("48967 c_blist 0 0 0 0 0 0 0 0 17 185 302 882 942 999 1591 1592 4083 5065 5068 5069 5070 5206 5307 5361 5982 5991".encode("ascii"), Client._ENCRYPTION_TABLE), b"\x86\x8C\xDA\xB1\x07\x9C\xA0\x9D\x93\x96\x8C\x8B\xE4\x11\x41\x41\x41\x41\x41\x41\x41\x41\x5B\x15\xC9\x17\x46\x1C\xC6\x1D\x86\x1D\xDD\x15\x9D\x51\x59\xD6\x18\x4C\x71\x94\xA9\x19\x4A\xC1\x94\xAD\x19\x4B\x41\x96\x4A\x19\x74\xB1\x97\xA5\x19\xDC\x61\x9D\xD5\xFF")
def test_real_client_pack_special_characters(self): self.assertEqual(Utils._Pack("14326 say dfskjda12312ąśąźżźżććżąąąśąąą2137dadaęóąśłżźćń;1122".encode("cp1250"), Client._ENCRYPTION_TABLE), b"\x86\x58\x76\xA1\x03\x8C\x9E\x86\x81\x10\x07\x9B\x99\x8C\x94\x95\x9B\x9E\x85\x56\x75\x60\x11\x46\x63\x46\x60\x40\x60\x40\x19\x19\x40\x46\x46\x46\x63\x46\x46\x46\x84\x65\x7B\x0E\x9B\x9E\x9B\x9E\x15\x0C\x46\x63\x4C\x40\x60\x19\x0E\xC4\x84\x55\x66\xFF")
def test_real_client_pack(self): self.assertEqual(Utils._Pack("17535 walk 20 26 1 11".encode("ascii"), Client._ENCRYPTION_TABLE), b"\x86\x5B\x97\x91\x04\x88\x9E\x93\x94\x8B\x16\x41\x6A\x15\x15\x50\xFF")
def test_server_pack_client_unpack(self): self.assertEqual(Utils._Unpack(Utils._Pack("2137 say ąźć123pd".encode("cp1250"), Client._ENCRYPTION_TABLE), Client._DECRYPTION_TABLE), "2137 say ąźć123pd".encode("cp1250"))
def test_client_mask_generator(self): packet = "14326 say dfskjda12312ąśąźżźżććżąąąśąąą2137dadaęóąśłżźćń;1122".encode("cp1250") generated_mask = "".join([str(int(i)) for i in Utils._GetMask(packet, Client._ENCRYPTION_TABLE)]) self.assertEqual(generated_mask, "1111110001000000011111000000000000000001111000000000000001111")
def WorldDecrypt(packet): return Utils._Unpack(packet, _DECRYPTION_TABLE)
def WorldEncrypt(packet, session, is_first_packet=False): packed = Utils._Pack(packet, _ENCRYPTION_TABLE) return _WorldXor(packed, session, is_first_packet)