Ejemplo n.º 1
0
        static void WriteLockInfo(MifareUltralight tag)
        {
            byte[] pages = tag.ReadPages(0);

            if (pages == null || pages.Length != TagUtil.PAGE_SIZE * 4)
            {
                throw new Exception("Read failed");
            }

            //lock bits
            tag.WritePage(2, new byte[] {
                pages[2 * TagUtil.PAGE_SIZE],
                pages[(2 * TagUtil.PAGE_SIZE) + 1],
                (byte)0x0F,
                (byte)0xE0
            }
                          );
            //dynamic lock bits. should the last bit be 0xBD accoridng to the nfc docs though:
            //Remark: Set all bits marked with RFUI to 0, when writing to the dynamic lock bytes.
            tag.WritePage(130, new byte[] { (byte)0x01, (byte)0x00, (byte)0x0F, (byte)0x00 });
            //config
            tag.WritePage(131, new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04 });
            //config
            tag.WritePage(132, new byte[] { (byte)0x5F, (byte)0x00, (byte)0x00, (byte)0x00 });
        }
Ejemplo n.º 2
0
        static void WritePassword(MifareUltralight tag)
        {
            byte[] pages0_1 = tag.ReadPages(0);

            if (pages0_1 == null || pages0_1.Length != TagUtil.PAGE_SIZE * 4)
            {
                throw new Exception("Read failed");
            }

            byte[] uid      = TagUtil.UidFromPages(pages0_1);
            byte[] password = TagUtil.Keygen(uid);

            tag.WritePage(0x86, new byte[] { (byte)0x80, (byte)0x80, (byte)0, (byte)0 });

            tag.WritePage(0x85, password);
        }
Ejemplo n.º 3
0
 static void WritePages(MifareUltralight tag, byte pagestart, byte pageend, byte[][] data)
 {
     for (byte i = pagestart; i <= pageend; i++)
     {
         tag.WritePage(i, data[i]);
     }
 }