private void button_string_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet();
            packet.WriteString(textBox_PBuilder.Text);

            textBox_PBuilderOut.Text += packet.ToPacketsString();
        }
        private void button_int8_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet();

            try
            {
                if (checkBox_int8.Checked)
                {
                    sbyte s = SByte.Parse(textBox_PBuilder_int8.Text);
                    packet.WriteByte((byte) (s & 0xFF));
                }
                else
                {
                    byte s = Byte.Parse(textBox_PBuilder_int8.Text);
                    packet.WriteByte(s);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("Error parsing!\r\n\r\n" + ee.ToString());
            }

            textBox_PBuilderOut.Text += packet.ToPacketsString();
        }
        private void button_int16_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet();

            try
            {
                if (checkBox_int16.Checked)
                {
                    ushort s = UInt16.Parse(textBox_PBuilder_int16.Text);
                    packet.WriteUShort(s);
                }
                else
                {
                    short s = Int16.Parse(textBox_PBuilder_int16.Text);
                    packet.WriteShort(s);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("Error parsing!\r\n\r\n" + ee.ToString());
            }
            textBox_PBuilderOut.Text += packet.ToPacketsString();
        }
        private void button_int64_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet();

            if (checkBox_int64.Checked)
            {
                ulong s = UInt64.Parse(textBox_PBuilder_int64.Text);
                packet.WriteLong((long) (s & 0xFFFFFFFFFFFFFFFF));
            }
            else
            {
                long s = Int64.Parse(textBox_PBuilder_int64.Text);
                packet.WriteLong(s);
            }
            textBox_PBuilderOut.Text += packet.ToPacketsString();
        }
        private void Compute(int min, int max)
        {
            Random r = new Random();
            StringBuilder sb = new StringBuilder();
            int pendingCounts = 0;

            for (int i = min; i < max; i++)
            {
                int order = 0;
                foreach (int z in mapids)
                {
                    if (z != i)
                    {
                        int TargetMap = z | i;
                        if (z != TargetMap)
                        {
                            string hashIndex = string.Format("{0}{1}", TargetMap, z);
                            if (FlagDuplicates.Contains(hashIndex))
                            {
                                continue; // already there
                            }

                            string mapname = WZFactory.getMapNameEx(TargetMap);
                            if (mapname != null)
                            {
                                Packet packet = new Packet();
                                packet.WriteInt(i);

                                // Start with indexes
                                sb.Append(z); // From map
                                sb.Append(" ");
                                sb.Append(TargetMap); // ToMap
                                sb.Append(" [");
                                sb.Append(packet.ToPacketsString());
                                sb.Append("]");

                                // Human readable
                                sb.Append(" ||| ");
                                sb.Append(mapstrs[order]);
                                sb.Append(" > ");
                                sb.Append(mapname);

                                if (!FlagDuplicates.Contains(hashIndex))
                                    FlagDuplicates.Add(hashIndex);


                                pendingCounts++;
                                if (pendingCounts > 50)
                                {
                                    Debug.WriteLine(sb.ToString());
                                    sb.Clear();
                                }
                                else
                                {
                                    sb.Append("\r\n");
                                }
                            }
                        }
                    }
                    order++;
                }
            }
            // others
            Debug.WriteLine(sb.ToString());
            sb.Clear();
        }
        private void button_RSA_Click(object sender, EventArgs e)
        {
            if (!File.Exists("WzCrypto.dll"))
            {
                MessageBox.Show("WzCrypto.dll is missing, please place it in the executable directory.");
                return;
            }
            if (textBox_user.Equals(String.Empty) || textBox_RSA.Equals(String.Empty) || textBox_HWID.Equals(String.Empty))
            {
                MessageBox.Show("Password, HWID or RSA cannot be empty!");
                return;
            }
            else if (textBox_HWID.Text.Length != 21)
            {
                MessageBox.Show("Desired HWID length must be 21! To prevent banning, please also follow the format..");
                return;
            }
            // Read
            PacketReader read = new PacketReader(ByteUtils.HexToBytes(textBox_RSA.Text));
  //          read.Skip(2); // Header
            int len = read.ReadShort();
            byte[] RSAKey = read.ReadBytes(len);

            // Write
            StringBuilder sb = new StringBuilder("Header : ");
            sb.Append((int)SendOps.LOGIN);
            Packet packet = new Packet(SendOps.LOGIN);

            sb.Append(" User : "******" HWID : ").Append(textBox_HWID.Text);
            packet.WriteString(textBox_HWID.Text);
            packet.WriteHexAsBytes("00 00 00 00 00 00 A3 27 64 60 00 00 00 00 0E 92 00 00 00 00 02 00");
    //        packet.WriteHexAsBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

            textBox_RSAOutput.Text = packet.ToPacketsString();
            textBox_hwidoutputRead.Text = sb.ToString();

            Properties.Settings.Default.hwid_acc = textBox_user.Text;
            Properties.Settings.Default.hwid_pass = textBox_password.Text;
            Properties.Settings.Default.hwid_default = textBox_HWID.Text;
            Properties.Settings.Default.Save();
        }