public bool StartEncryption(string username, string sessionID, byte[] token, string serverIDhash, java.security.PublicKey serverKey, javax.crypto.SecretKey secretKey)
        {
            Console.ForegroundColor = ConsoleColor.DarkGray;
            ConsoleIO.WriteLine("Crypto keys & hash generated.");
            Console.ForegroundColor = ConsoleColor.Gray;

            if (serverIDhash != "-")
            {
                Console.WriteLine("Checking Session...");
                if (!SessionCheck(username, sessionID, new java.math.BigInteger(Crypto.getServerHash(serverIDhash, serverKey, secretKey)).toString(16)))
                {
                    return false;
                }
            }

            //Encrypt the data
            byte[] key_enc = Crypto.Encrypt(serverKey, secretKey.getEncoded());
            byte[] token_enc = Crypto.Encrypt(serverKey, token);
            byte[] keylen = BitConverter.GetBytes((short)key_enc.Length);
            byte[] tokenlen = BitConverter.GetBytes((short)token_enc.Length);

            Array.Reverse(keylen);
            Array.Reverse(tokenlen);

            //Building the packet
            byte[] data = new byte[5 + (short)key_enc.Length + (short)token_enc.Length];
            data[0] = 0xFC;
            keylen.CopyTo(data, 1);
            key_enc.CopyTo(data, 3);
            tokenlen.CopyTo(data, 3 + (short)key_enc.Length);
            token_enc.CopyTo(data, 5 + (short)key_enc.Length);

            //Send it back
            Send(data);

            //Getting the next packet
            byte[] pid = new byte[1];
            Receive(pid, 0, 1, SocketFlags.None);
            if (pid[0] == 0xFC)
            {
                readData(4);
                setEncryptedClient(Crypto.SwitchToAesMode(c.GetStream(), secretKey));
                return true;
            }
            else return false;
        }
        public bool StartEncryption(string uuid, string sessionID, byte[] token, string serverIDhash, java.security.PublicKey serverKey, javax.crypto.SecretKey secretKey)
        {
            Console.ForegroundColor = ConsoleColor.DarkGray;
            ConsoleIO.WriteLine("Crypto keys & hash generated.");
            Console.ForegroundColor = ConsoleColor.Gray;

            if (serverIDhash != "-")
            {
                Console.WriteLine("Checking Session...");
                if (!SessionCheck(uuid, sessionID, new java.math.BigInteger(Crypto.getServerHash(serverIDhash, serverKey, secretKey)).toString(16)))
                {
                    return false;
                }
            }

            //Encrypt the data
            byte[] key_enc = Crypto.Encrypt(serverKey, secretKey.getEncoded());
            byte[] token_enc = Crypto.Encrypt(serverKey, token);
            byte[] key_len = BitConverter.GetBytes((short)key_enc.Length); Array.Reverse(key_len);
            byte[] token_len = BitConverter.GetBytes((short)token_enc.Length); Array.Reverse(token_len);

            //Encryption Response packet
            byte[] packet_id = getVarInt(0x01);
            byte[] encryption_response = concatBytes(packet_id, key_len, key_enc, token_len, token_enc);
            byte[] encryption_response_tosend = concatBytes(getVarInt(encryption_response.Length), encryption_response);
            Send(encryption_response_tosend);

            //Start client-side encryption
            setEncryptedClient(Crypto.SwitchToAesMode(c.GetStream(), secretKey));

            //Get the next packet
            readNextVarInt(); //Skip Packet size (not needed)
            return (readNextVarInt() == 0x02); //Packet ID. 0x02 = Login Success
        }