Example #1
0
        private void RBAscii_CheckedChanged(object sender, EventArgs e)
        {
            BlockDataTextBox.SelectionAlignment = HorizontalAlignment.Center;

            if (TempCardsNumber == 0)
            {
                BlockDataTextBox.Clear();
            }
            else
            {
                String ascii = null;
                for (byte i = 0; i < 16; i++)
                {
                    if (TempData[i] < 20 || TempData[i] > 128)
                    {
                        ascii += ".";
                    }
                    else
                    {
                        ascii += ((char)TempData[i]).ToString();
                    }
                }

                BlockDataTextBox.Text = ascii;
            }
        }
Example #2
0
        private void bEnumCards_Click(object sender, EventArgs e)
        {
            EnumTextBox.Clear();
            CardComboBox.Items.Clear();
            BlockDataTextBox.Clear();
            SelectedCardTextBox.Text = "Card not selected";
            TempCardsNumber          = 0;
            byte CardsNumber = 0;
            byte ListSize    = 0;
            byte index       = 0;

            byte[] list = new byte[44];

            unsafe
            {
                status = uFCoder.EnumCards(&CardsNumber, &ListSize);

                TempCardsNumber = CardsNumber;

                if (status == 0)
                {
                    EnumTextBox.AppendText("There is " + CardsNumber.ToString() + " card(s) in the reader field.");

                    if (CardsNumber > 0)
                    {
                        status = uFCoder.ListCards(list, ListSize);

                        if (status != 0)
                        {
                            MessageBox.Show("Unable to enumerate cards!");
                        }
                        else
                        {
                            index = 0;
                            EnumTextBox.AppendText("\n\nUid list of the cards in the reader field:\n");


                            for (byte i = 0; i < CardsNumber; i++)
                            {
                                EnumTextBox.AppendText("\n" + (i + 1).ToString() + ". ");

                                EnumTextBox.AppendText(ByteArrayToString(list, (byte)(index + 1), (byte)(list[index] + index + 1)));

                                index += 11;

                                CardComboBox.Items.Add((i + 1).ToString());
                            }

                            CardComboBox.SelectedIndex = CardComboBox.Items.IndexOf("1");
                        }

                        TempUid = list.ToArray();
                    }
                }
                else
                {
                    MessageBox.Show("Error while trying to enumerate cards!");
                }
            }
        }
Example #3
0
        private void RBHexadecimal_CheckedChanged(object sender, EventArgs e)
        {
            BlockDataTextBox.SelectionAlignment = HorizontalAlignment.Center;

            if (TempCardsNumber == 0)
            {
                BlockDataTextBox.Clear();
            }
            else
            {
                BlockDataTextBox.Text = BitConverter.ToString(TempData).Replace("-", ":");
            }
        }
Example #4
0
        private void RBDecimal_CheckedChanged(object sender, EventArgs e)
        {
            BlockDataTextBox.SelectionAlignment = HorizontalAlignment.Center;

            if (TempCardsNumber == 0)
            {
                BlockDataTextBox.Clear();
            }
            else
            {
                String decimal_data = null;
                for (int i = 0; i < 16; i++)
                {
                    decimal_data += ((int)TempData[i]).ToString() + ":";
                }
                decimal_data          = decimal_data.Substring(0, decimal_data.Length - 1);
                BlockDataTextBox.Text = decimal_data;
            }
        }
Example #5
0
        private void bReadBlock_Click(object sender, EventArgs e)
        {
            BlockDataTextBox.Clear();
            String address_str = blockAddressTextBox.Text;
            String key_str     = Byte1TB.Text + Byte2TB.Text + Byte3TB.Text + Byte4TB.Text + Byte5TB.Text + Byte6TB.Text;
            byte   auth_mode   = 0;

            byte[] Data = new byte[16];
            byte[] key  = new byte[6];

            UInt16 block_address = UInt16.Parse(address_str);

            if (radioButtonAKey.Checked == true)
            {
                auth_mode = 0x60;
            }
            else if (radioButtonBKey.Checked == true)
            {
                auth_mode = 0x61;
            }

            key = ToByteArray(key_str);

            status = uFCoder.BlockRead_PK(Data, block_address, auth_mode, key);

            Array.Copy(Data, 0, TempData, 0, 16);

            if (status == 0)
            {
                BlockDataTextBox.SelectionAlignment = HorizontalAlignment.Center;

                if (RBHexadecimal.Checked == true)
                {
                    BlockDataTextBox.Text = BitConverter.ToString(Data).Replace("-", ":");
                }
                else if (RBDecimal.Checked == true)
                {
                    String decimal_data = null;
                    for (int i = 0; i < 16; i++)
                    {
                        decimal_data += ((int)Data[i]).ToString() + ":";
                    }
                    decimal_data          = decimal_data.Substring(0, decimal_data.Length - 1);
                    BlockDataTextBox.Text = decimal_data;
                }
                else if (RBAscii.Checked == true)
                {
                    String ascii = null;
                    for (byte i = 0; i < 16; i++)
                    {
                        if (Data[i] < 20 || Data[i] > 128)
                        {
                            ascii += ".";
                        }
                        else
                        {
                            ascii += ((char)Data[i]).ToString();
                        }
                    }

                    BlockDataTextBox.Text = ascii;
                }
            }
            else
            {
                MessageBox.Show("Unable to read block " + address_str);
            }
        }