public encrypt ( byte plainData, int length, |
||
plainData | byte | |
length | int | |
pss | ||
cseq | ||
sseq | ||
Результат | byte[] |
public int enigmaLibEncryption() { try{ WorldEncryption we = new WorldEncryption(); byte[] p = new byte[16]; we.encrypt(p, 16, 15, 15, 15); } catch (Exception e) { Output.Write("Failed\n"); Output.WriteLine("Debug: " + e); return(0); } Output.Write("OK\n"); return(1); }
public int enigmaLibEncryption() { try{ WorldEncryption we = new WorldEncryption(); byte[] p = new byte[16]; we.encrypt(p,16,15,15,15); } catch(Exception e){ Output.Write("Failed\n"); Output.WriteLine("Debug: "+e); return 0; } Output.Write("OK\n"); return 1; }
// Flush the MessageQueue Lists to the Client public void flushQueue() { // This resend the MessageQueue - should be called after parsing or after sending something out // or in a timed interval (keep alive for example) // Sends RAW MEssages sendRawMessages(); Output.WriteLine("[CLIENT] In Queue Messages : " + messageQueue.ObjectMessagesQueue.Count.ToString() + " Object and " + messageQueue.RPCMessagesQueue.Count.ToString() + " RPC Messages"); ArrayList worldPackets = new ArrayList(); WorldPacket packet = new WorldPacket(playerData); // Init encrypted Packet if we have MPM Messages if (messageQueue.RPCMessagesQueue.Count > 0 || messageQueue.ObjectMessagesQueue.Count > 0 && flushingQueueInProgress == false) { flushingQueueInProgress = true; // we currently dont know if we send something out so we need to proove that in a way if (messageQueue.ObjectMessagesQueue.Count > 0) { UInt16 sendingSSeq = playerData.calculateNextPossibleSseq(); lock (messageQueue.ObjectMessagesQueue.SyncRoot) { foreach (SequencedMessage messageObjects in messageQueue.ObjectMessagesQueue) { // Just append each message... if (messageObjects.getResendTime() >= TimeUtils.getUnixTimeUint32() || messageObjects.getResendTime() == 0) { // Check if this really save the resendtime or not messageObjects.increaseResendTime(); bool canAddThePak = packet.addObjectContent(messageObjects); if (canAddThePak == false) { packet.isFinal = true; // if one sub has a timed param set, we just set it here too worldPackets.Add(packet); // Start new packet and add it to the queue packet = new WorldPacket(playerData); packet.addRPCContent(messageObjects); } if (messageObjects.isTimed == true) { packet.timed = true; } } } } } // Workaround: complete the packet so we dont mix up if (packet.ObjectMessages.Count > 0) { packet.isFinal = true; worldPackets.Add(packet); packet = new WorldPacket(playerData); packet.timed = false; } if (messageQueue.RPCMessagesQueue.Count > 0) { lock (messageQueue.RPCMessagesQueue.SyncRoot) { foreach (SequencedMessage messageRPC in messageQueue.RPCMessagesQueue) { // First do stuff on messages // Just append each message... if (messageRPC.getResendTime() >= TimeUtils.getUnixTimeUint32() || messageRPC.getResendTime() == 0) { // Check if this really save the resendtime or not messageRPC.increaseResendTime(); if (packet.addRPCContent(messageRPC) == false) { packet.isFinal = true; worldPackets.Add(packet); // Start new packet and add it to the queue packet = new WorldPacket(playerData); packet.addRPCContent(messageRPC); } if (messageRPC.isTimed == true) { packet.timed = true; } } } } } // Check if the current not finalize packet has content and needs to be send if ((packet.isFinal == false) && (packet.ObjectMessages.Count > 0 || packet.RPCMessages.Count > 0)) { worldPackets.Add(packet); } } // We have nothing - but we should really ack this if (messageQueue.ackOnlyCount > 0) { for (int i = 0; i < messageQueue.ackOnlyCount; i++) { WorldPacket ackPacket = new WorldPacket(playerData); packet.isFinal = true; packet.timed = false; worldPackets.Add(ackPacket); } messageQueue.ackOnlyCount = 0; } // We have now PacketObjects - time to send them if (worldPackets.Count > 0) { Output.WriteLine("[CLIENT] Flush the final Queue with " + worldPackets.Count.ToString() + " Packets"); foreach (WorldPacket thePacket in worldPackets) { playerData.IncrementSseq(); byte[] finalData = thePacket.getFinalData(playerData); Output.WritePacketLog(StringUtils.bytesToString(finalData), "SERVER", playerData.getPss().ToString(), playerData.getCseq().ToString(), playerData.getSseq().ToString()); byte[] encryptedData = cypher.encrypt(finalData, finalData.Length, playerData.getPss(), playerData.getCseq(), playerData.getSseq()); sendPacket(encryptedData); Output.WriteDebugLog("PACKET SEND FINALLY (WC AFTER sendPacket):" + StringUtils.bytesToString(finalData)); } } flushingQueueInProgress = false; }