Ejemplo n.º 1
0
        //Use a key group to read the card
        public byte[] ReadData(ReadWriteTypeModeEnum rm, KeyModeEnum km, byte blockNo, byte keyGroupIndex, out byte[] cardSerialData)
        {
            //byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            cardSerialData = SelectCard();
            if (cardSerialData == null)
            {
                return(null);
            }
            if (CheckReaderKey(keyModel, blockNo, keyGroupIndex))
            {
                byte[] pData    = new byte[100];
                ulong  pDataLen = 0;
                int    r        = MasterRDImprot.rf_M1_read(0, blockNo, pData, ref pDataLen);
                if (r == 0)
                {
                    byte[] resultData = new byte[pDataLen];
                    for (int i = 0; i < (int)pDataLen; i++)
                    {
                        resultData[i] = pData[i];
                    }
                    return(resultData);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public byte[] ReadData(KeyModeEnum km, byte blokNo, string keyStr, out byte[] cardSerialData)
        {
            // byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            byte[] key      = GetKeyData(keyStr);
            byte[] pData    = new byte[100];
            ulong  pdataLen = 0;

            //Reading card serial number
            cardSerialData = SelectCard();
            if (cardSerialData == null)
            {
                return(null);
            }
            int r;

            //check key
            r = MasterRDImprot.rf_M1_authentication2(0, keyModel, blokNo, key);

            r = MasterRDImprot.rf_M1_read(0, blokNo, pData, ref pdataLen);
            if (r == 0)
            {
                byte[] rData = new byte[pdataLen];
                for (int i = 0; i < (int)pdataLen; i++)
                {
                    rData[i] = pData[i];
                }
                return(rData);
            }
            return(null);
        }
Ejemplo n.º 3
0
        //Use key groups to write data
        public bool WriteData(ReadWriteTypeModeEnum rm, KeyModeEnum km, byte blockNo, byte keyGroupIndex, string pDataStr)
        {
            byte readModel = (byte)rm;
            byte keyModel  = (byte)km;

            SelectCard();
            if (CheckReaderKey(keyModel, blockNo, keyGroupIndex))
            {
                byte[] pData = GetWriteData(pDataStr);
                int    r     = MasterRDImprot.rf_M1_write(0, blockNo, pData);
                return(r == 0 ? true : false);
            }
            return(false);
        }
Ejemplo n.º 4
0
        //Use key to write data
        public bool WriteData(KeyModeEnum km, byte blockNo, string keyStr, string pDataStr)
        {
            //byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            byte[] key   = GetKeyData(keyStr);
            byte[] pData = GetBlockData(pDataStr);
            ulong  pLen  = (ulong)pData.Length;

            SelectCard();
            int r;

            //Check key
            r = MasterRDImprot.rf_M1_authentication2(0, keyModel, blockNo, key);

            r = MasterRDImprot.rf_M1_write(0, blockNo, pData);
            return(r == 0 ? true : false);
        }