Esempio n. 1
0
        public bool ClearAllBlock()
        {
            //var res = false;

            isoReaderInit();
            card = new MifareCard(isoReader);

            var data = new byte[16];

            if (card.LoadKey(KeyStructure.VolatileMemory, 0x00, key))
            {
                for (byte i = 1; i <= 63; i++)
                {
                    if ((i + 1) % 4 == 0)
                    {
                    }
                    else
                    {
                        if (card.Authenticate(Msb, i, KeyType.KeyA, 0x00))
                        {
                            Array.Clear(data, 0, 16);
                            if (WriteBlock(Msb, i, data))
                            {
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        public byte[] ReadBlock(byte msb, byte lsb)
        {
            isoReaderInit();
            card = new MifareCard(isoReader);

            var readBinary = new byte[16];

            if (card.LoadKey(KeyStructure.VolatileMemory, 0x00, key))
            {
                if (card.Authenticate(msb, lsb, KeyType.KeyA, 0x00))
                {
                    readBinary = card.ReadBinary(msb, lsb, 16);
                }
            }

            return(readBinary);
        }
Esempio n. 3
0
        public bool WriteBlock(byte msb, byte lsb, byte[] data)
        {
            isoReaderInit();
            card = new MifareCard(isoReader);

            if (card.LoadKey(KeyStructure.VolatileMemory, 0x00, key))
            {
                if (card.Authenticate(msb, lsb, KeyType.KeyA, 0x00))
                {
                    if (card.UpdateBinary(msb, lsb, data))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }