Thank you all for helping. I'm discontinued the project cause I'm can be crazy because of the crazy crypto and now I'm back again to face with the crypto again. So, I get a broken packet and I'm using the Azure Packet Processor.

This is my handshake event :
Code:
internal void InitCrypto()
{
Response.Init(Outgoing.InitCryptoMessageComposer);
Response.AppendString(HabboEncryptionHandlerV2.GetRsaDiffieHellmanPrimeKey());
Response.AppendString(HabboEncryptionHandlerV2.GetRsaDiffieHellmanGeneratorKey());
SendResponse();
}
internal void GenerateSecretKey()
{
var cipherKey = Request.GetString();
BigInteger sharedKey = HabboEncryptionHandlerV2.CalculateDiffieHellmanSharedKey(cipherKey);
if (sharedKey != 0)
{
Response.Init(Outgoing.SecretKeyMessageComposer);
Response.AppendString(HabboEncryptionHandlerV2.GetRsaDiffieHellmanPublicKey());
Response.AppendBool(false);
SendResponse();
var data = sharedKey.getBytes();
if (data[data.Length - 1] == 0)
Array.Resize(ref data, data.Length - 1);
Array.Reverse(data, 0, data.Length);
Session.GetConnection().ARC4ServerSide = new ARC4(data);
//Session.GetConnection().ARC4Clientide = new ARC4(data);
}
else
Console.WriteLine("Crypto Error");
}
This is my game packet parser
Code:
if (data.Length == 0 || _currentClient == null)
return;
Console.WriteLine(data.Length);
int pos = 0;
short messageId = 0;
try
{
for (pos = 0; pos < data.Length;)
{
int length = HabboEncoding.DecodeInt32(new[] { data[pos++], data[pos++], data[pos++], data[pos++] });
if (length < 2 || length > 4096)
{
Console.WriteLine("Broken packet with {0} length", length);
return;
}
messageId = HabboEncoding.DecodeInt16(new[] { data[pos++], data[pos++] });
byte[] packetContent = new byte[length - 2];
for (int i = 0; i < packetContent.Length && pos < data.Length; i++)
packetContent[i] = data[pos++];
using (ClientMessage clientMessage = new ClientMessage(messageId, packetContent))
{
_currentClient.GetMessageHandler().HandleRequest(clientMessage);
}
}
}
catch (Exception exception)
{
Console.WriteLine("GamePacketParser >> {0}", exception.Message);
_connection.Dispose();
}
P/S: I'm a newbie..