Пример #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);
        }
Пример #2
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);
        }